Linux monitors the running shell scripts of a process
This script scans and monitors the process with the specified process name at intervals of 2. Once the process does not exist, it restarts.
#! /Bin/sh
A = 10;
While [[@ a-gt 5]; do
If test $ (pgrep-f $1 | wc-l)-eq 2; then
Sh stop. sh
Gnome-terminal-x sh start. sh &
Fi;
Sleep 2;
Done;
Conclusion: (1) & indicates that the current process starts another process to execute the gnome-terminal command; (2) if the parent process in linux crashes, the child process does not, instead, set the parent process of the child process to 1 (init process); (3) view the command jobs-l of the background running process; view the method of the parent process of process 20197, ps-ef | grep 20197.
My problem: pgrep-f $1 | the running status of wc-l in sh is different from that in the terminal. Why does the execution in sh not exist, is it 2 ?, Welcome to comments and discussions ~~