I have a python script that I run everyday at 00:00 as a cronjob & its lasts for about 5-6 hours. I want supervisor to monitor the script & restart if it hangs/crashes in the middle.

I have done something like this:

command=python run.py

This works but the only problem is it tries to restart the even after the completion of the script. What should do to check if the script has completed execution or crashed in the middle. I want supervisor to run only if it crashed.

Is there anything I can do in python script that signals supervisor that it has completed execution, so, supervisor don't have to restart it again?

Thanks for any help.

Re: Supervisord restart script only if it crashed 80 80

check the Process States documentation:

In practice: define the expected exitcodes for the script and then set autorestart=unexpected so that it will restart only when it does not match.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.