Views: 
              4,821β
          
          
                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: 
              October 19, 2025
          
          
               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