The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 4,589β€…    Votes:  1β€…    βœ… Solution
Tag : cron  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

URL: https://askubuntu.com/q/1188218
Title: Run script every 4 minutes but don't run from 3:00 to 3:40
ID: /2019/11/12/Run-script-every-4-minutes-but-don_t-run-from-3_00-to-3_40
Created: November 12, 2019
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Stack Overflow has a good answer similar to your problem:

In this answer a job runs every 15 minutes except blackout period from 3am to 4am at which time another job is run:

# 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  

If you don’t have another job to run during the blackout period remove the last two lines.

You can combine your two lines of:

*/4 0-3 * * * example.sh
*/4 4-0 * * * example.sh

With one line of:

*/4 0-2,4-23 * * * example.sh

Then for your last complicated line:

40,44,48,52,56 4 * * * example.sh

Replace it with:

40-59/4 3 * * * example.sh
⇧ Should I turn off kernel logging (and how?) if I'm running off an SSD? Output redirection to a file, used inside script, is not working when executed from crontab  β‡©