This article describes the shell script, through a while-do loop, with Ps-ef|grep check whether the loader process is running, if not run, then start to ensure that the crash hangs the process, and automatically restart in a timely manner.
The script reads as follows:
Note:
1, PS | grep must add a path to a process, or grep will have an unknown error,
2, you must remove the grep command itself from the result with-V, otherwise the result is not empty.
If you start this shell and discover that the process already exists, it means that the process is started in another way instead of the shell, and it continues to alert you to the process.
Workaround:
Just start the service with this shell , or kill it once you discover that the service started in another way, which is the sentence in the above script:
Kill-9 $pidof $PWD/loader
A shell script that automatically restarts after the monitoring process hangs on Linux