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.