: Retry cron job until it successfully excecutes I'm running a python script on my VPS every day with cron. It only has 768mb ram, and when I run the script manually I often get memory errors
I'm running a python script on my VPS every day with cron. It only has 768mb ram, and when I run the script manually I often get memory errors from python. However, I usually can just try a couple more times and it works.
Obviously, cron only runs it once, and this means that most days the task doesn't happen.
Is there a way to monitor python's output and tell cron to keep running until it runs without errors?
Obviously i would put a limit of say 5 runs on, so it doesn't go forever and crash my server.
Additionally, are there some command line Linux tools to free up memory before it runs, to increase chances of it working? I'm running Ubuntu Server 11.04
More posts by @Yeniel560
1 Comments
Sorted by latest first Latest Oldest Best
Cron is only run "once" at specific time or "every" minutes/hours.
It doesn't check the return code. But a wrapper script CAN check the output.
I suggest that you launch a "wrapper" to your script, then, the script will check itself for the presence of a file "/tmp/runcomplete", check for the run counter in another file, well, you get the idea.
From my opinion :
Fix your app memory problem, programs should be 1 or 0, not try it may work
Take another server or consider cloud computing with on demand instances
Look at the script memory usage and tweak your vm memory kernel settings (sysctl.conf)
Regards
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.