how to not run a cron job between certain datetimes


Say, I have a cron job entry and do not want the job to run between 2013-02-01 9PM (Feb 1st 2013) and 2013-02-02 11AM (Feb 2nd 2013), this is one possible solution (in crontab).

* * * * * [ $(/bin/date "+\%Y\%m\%d\%H") -lt 2013020109 -o $(/bin/date "+\%Y\%m\%d\%H") -gt 2013020211 ] && /PATHTOMYSCRIPT/myscript

Leave a Reply

Your email address will not be published. Required fields are marked *