Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do i setup a cronjob to run every hour except from 11pm until 1am ?

Because during that time, the system is doing maintenance.


share|improve this question

migrated from May 16 '12 at 9:01

This question came from our site for professional and enthusiast programmers.

what does this question have to do with c#? I am removing the tag. – izomorphius Apr 18 '12 at 8:26
Read the crontab(5) manpage. – David-SkyMesh Apr 18 '12 at 8:28
did you checked man 5 crontab? – tuxuday Apr 18 '12 at 8:30
I did. Obviously i can't figure it out. – overule Apr 18 '12 at 8:42

1 Answer 1

up vote 3 down vote accepted

Three options:

  • Run the job every hour, but have the job itself be a script that checks the current time and immediately exits if it's between 11pm and 1am.

  • Specify all 21 hours that it should run:

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

(I think I got that right.)

  • If the version of cron you're using supports it, you can specify a range:

0 2-22 * * * do_something

man 5 crontab to confirm this.

share|improve this answer

Your Answer


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