Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a cron job that needs to run every 10 minutes, but should not be run for an hour each night (from 5 to 6am) while the system is down for a backup.

As I understand it the following syntax should work in crontab:

*/10 0,1,2,3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * *

This is hardly a nice solution, is there a more efficient way to express my needs to cron?

In case it matters, the server is running RHEL 5.

share|improve this question

2 Answers 2

up vote 11 down vote accepted

Cron on RHEL supports lists, so you can just do this:

*/10 0-4,6-23 * * *
share|improve this answer
    
perfect - nice and neat and legible, not like my big pile of glop! Thanks! –  Bart B Feb 9 '10 at 16:06

Use another service to shutdown cron service during that time. Maybe at?

Although David's idea sounds ... simpler.

Schedule the maintenance script with cron - let the script shutdown cron and at the end restart it again. No matter how long your maintenance script will take, no job will interfere. As soon as it is done everything is fine again and you may not even have missed a thing.

To allow for crasing maintenance script schedule a startup of cron service with at in now + x hours.

share|improve this answer
    
What if you have other jobs that need to run during that time? –  Dennis Williamson Feb 9 '10 at 13:44
    
I just took a guess that no jobs should run during that hour (maintenance or something). –  StampedeXV Feb 9 '10 at 16:04
    
actually - the maintenance scripts that run during that hour are run by cron - so not a runner. Thinking outside the box though, nice! –  Bart B Feb 9 '10 at 16:07
    
extended answer. Just to stick with my original idea. –  StampedeXV Feb 9 '10 at 19:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.