Crontab run every 15 minutes except at 3AM?

LinuxUnixCron

Linux Problem Overview


Is it possible to have a cronjob run every 15 minutes (over every hour etc..) except for at 3AM?

I have another special cronjob I want to run at 3AM, but I don't want the other one to run at the same time...

Linux Solutions


Solution 1 - Linux

With one cron line, no. With three, yes:

# 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

Solution 2 - Linux

I made my own solution, but I wanted to see what other people thought of!

I put this on the top of my desired script. I wanted it to not run at the half hour either so 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.

Solution 3 - Linux

 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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEric SeifertView Question on Stackoverflow
Solution 1 - LinuxfgeView Answer on Stackoverflow
Solution 2 - LinuxEricView Answer on Stackoverflow
Solution 3 - LinuxrichrosaView Answer on Stackoverflow