The script implements a 2-per-scan monitoring of the process for the specified process name and restarts once the discovery process does not exist.
#!/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
Summary: (1) & indicates that the current process starts a process to execute the gnome-terminal command, (2) The parent process of Linux hangs up, the child process is not hung, but the parent process of the child process is set to 1 (init process), and (3) The command jobs-l to view the running process in the background; View the method Ps-ef|grep 20197 of the parent process for process 20197.
My question: pgrep-f $1|wc-l in SH and the result of running in the terminal is not the same, why do not exist in sh, is 2? , Welcome to comment discussion ~ ~
Linux monitors running shell scripts for a process