I have a cron job which runs every five minutes all day long.
I want to stop this cron job running on Sundays between 4pm and 5pm – it should start again after this time.
How can I script this?
cronjob
I have a cron job which runs every five minutes all day long.
I want to stop this cron job running on Sundays between 4pm and 5pm – it should start again after this time.
How can I script this?
Best Answer
Stick this at the top of your cron job script (modified as you need)...
The first instance of "date" returns the day of week (Sunday = 7), the second returns the hour (16 = 4.00pm - 4.59pm). If the script finds that it's currently day 7 and hour 16, it will exit.