Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Cron Job - Linux / Python

Hi I have a Django script that I need to run,

I think the commands could be called through bash.

Thing is the script causes memory leaks after a long a period of time, so I would like to create an external cron job which calls the Python script. So the script would terminate and restart while retaking the lost memory.


Can someone point me in the right direction? I know quite little on the subject, and feel a bit lost.

like image 837
RadiantHex Avatar asked Dec 18 '22 02:12

RadiantHex


1 Answers

If you have an executable, say /home/bin/foobar, that restarts the script, and want to run it (say) every 10 minutes, the crontab entry needs to be:

*/10 * * * *  /home/bin/foobar

which says to run it at every minute divisible by 10, every hour, every day.

If you save this (and any other periodic jobs you want to run) as, say, /home/bin/mycrontab, then just do crontab /home/bin/crontab and the system will do the rest (the script runs with your userid).

To see what periodic jobs you have already scheduled under the current userid, if any, do crontab -l.

like image 72
Alex Martelli Avatar answered Dec 19 '22 14:12

Alex Martelli