Skip to content
Advertisement

Re-run a python script after a few days if it fails [closed]

Assuming a script fails and it is captured in a try catch how to run a python script again after a few days?

I can use sleep on this problem, but I think it will not work due to the fact that the server restarts every day. What is the best solution on this problem?

Advertisement

Answer

Typically you want to address this with a cron job.

I would probably do the following:

  1. When the python file runs, save a log file with the status date/time.
  2. Set up a cron job on the server to check, say once every 24 hours, that checks that log file and either do nothing or runs the python file again.
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement