I have a python program which I need to run every minute from 11PM (EDT) to 06AM (EDT). How can I schedule a cron job to do this?
* 23-6 * * 1-5 python my_program.py
will this work? or do I have to write 2 separate cron jobs for this?
cron
I have a python program which I need to run every minute from 11PM (EDT) to 06AM (EDT). How can I schedule a cron job to do this?
* 23-6 * * 1-5 python my_program.py
will this work? or do I have to write 2 separate cron jobs for this?
Best Answer
Ranges that wrap around like that are ambiguous. Specify the hours as
23,0-6
instead and avoid future problems.Cron checks every minute the contents of crontab files and if it founds coincidence of the time and the conditions it will run the script indicated on the line.
For this case these is the set of coincidences that must be met:
So, every minute during the time that the set of coincidences are true, it will run.
Don't expect it to run outside of the range of hours and days indicated, for example on saturday.