Supervise, a tool for process management in Linux

Source: Internet
Author: User
Article Title: Supervise, a tool for process management in Linux. Linux is a technology channel of the IT lab in China. It includes desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic categories. Supervise is a daemontools tool that can be used to monitor and manage the running status of unix applications, when an application exception occurs, supervise can restart the specified program. This article briefly introduces how to install and use supervise.
 
   I. Installation
 
Create/pacakage directory (you can create any directory. Here, the package is used to keep it consistent with that of the English author ):
 
Mkdir-p/package chmod 1755/package cd/package
 
Download daemontools-0.76.tar.gz to the/package directory and decompress the package.
 
Tar xvzf daemontools-0.76.tar.gz cd admin/daemontools-0.76
 
Compile and install the daemontools Program
 
Package/install
 
  2. Use the supervise program for program management and monitoring
 
The supervise execution command is supervise Path, where Path is the specified Path, which can be a relative Path or an absolute Path. Under the Path, there must be a run script. supervise calls this script and monitors and manages the programs running in this script.
 
An important function of supervise is to check whether the Program executed in the run script works normally. If it is found to have died, supervise will re-execute the run script and restart the specified program. This is very necessary for many server programs. No one wants to crawl out of the bed at am late at night and restart the server.
 
The following is an example of using supervise.
 
   Iii. Example
 
Assume that daemontools has been installed, create a test directory, and enter the Directory
 
Mkdir test cd test
 
Write a simple test program test. c In this directory:
 
  
#include 
  #include
  int main()
  {
   int ix = 0;
   for(;; ix++)
   {
   printf("%d\n", ix);
   sleep(1);
   }
   return 0;
  }


 
Compile test. c and output test.
 
Gcc-o test. c
 
Compile a script run to execute the test program so that supervise can call it.
 
  
  

#!/bin/sh
  echo "start test!"
  ./test


 
Return to the parent directory and execute supervise test to check the effect:
 
Cd ......
 
Supervise test
 
Run killall-9 test to kill the test process. You will find that supervise restarts the test process. Of course, if the program core dump, supervise will also restart the program.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.