Is it possible to schedule cronjobs to run every 15 minutes (over an hour, etc.) except at 3 a.m.?
I have another cronjob that I want to run at 3 a.m., but I don’t want it to run at the same time as the other…
Asked by Eric Seifert
No, with only one cron line. Yes, with three:
# Every 15 minutes except for 3:00-3:59 */15 0-2,4-23 * * * thejob # 3:15, 3:30, 3:45 15-45/15 3 * * * thejob # 3:00 dead 0 3 * * * otherjob
Answered by fge
I came up with my own solution, but I wanted to hear what others had to say!
This is what I put on top of my desired script. I didn’t want it to run at half-hour, thus it doesn’t do it on both.
On top of the script:
if [ $(date +%M) = 00 ] || [ $(date +%M) = 30 ] then exit fi
The cron line:
*/15 * * * * ~/path/to/file
Hope anyone uses my solution too.
Answered by Eric
0,15,30,45 0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * * your cron job
Answered by richrosa
Post is based on https://stackoverflow.com/questions/8764150/crontab-run-every-15-minutes-except-at-3am