Answer the question
In order to leave comments, you need to log in
How to track the status of the script in the crone and restart it if necessary?
I have such an entry in the crown, but it constantly spawns scripts:
*/10 * * * * ps aux|grep my_script| grep -v grep || exec /home/my_script > /home/log.txt &";
Answer the question
In order to leave comments, you need to log in
So, what's with the cron? You just specify the sh script to run in the crone. And in the script itself, already do the checks you want. You can write the pid of the running one to a file and look for such one among the running ones before starting. Or perhaps you can find it by name in the list of processes. In general, everything is in your hands.
You do not have the fact that the result of the pipe will be equal to non-zero, since this will be the return code of the last command in the pipe.
Try something like this:
*/10 * * * * [ "$(ps ax | grep my_script | grep -v grep)" == "" ] && /home/my_script > /home/log.txt &";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question