0

I am getting a Bad Hour error for the following crontab entry:

*/05 17-05 * * * wget -q -O /dev/null "http://abcd/cron/abcd"

Is there any issue with this? I want the cron to run from evening 5 PM to morning 5 AM

5

As you are not specifying which system you are using, I am hoping your system use a "Vixie" or "Vixie"-related crontab utility.

Still:

  • 17-05: is not considered a proper range (the lower limit being greater than the higher limit of the range).

You could instead write: "17-23,00-05"

From man 5 crontab:

 Ranges of numbers are allowed.  Ranges are two numbers separated with a
hyphen.  The specified range is inclusive.   For example, 8-11 for an
``hours'' entry specifies execution at hours 8, 9,  10 and 11.

So, sure nothing really forbiding you to write an interval the way you did.

The Extensions part of man 5 crontab is also interesting regarding how other crontab utilities would allow you specify more than a simple range (your system might be one of these):

 Lists and ranges are allowed to co-exist in the same field.
 "1-3,7-9" would be rejected by ATT or BSD cron -- they want to
see "1-3" or "7,8,9" ONLY.

So, as you can see, it really depends on your system crontab ability to understand what you mean by "17-05".

For more information:

  • but cron wont work for 1 hour between 11PM and 12AM right? – Hacker Apr 7 '14 at 7:32
  • @Hacker it will work for those times as expected. – cpugeniusmv Apr 7 '14 at 10:48
  • @Hacker: 11PM=23 and 12AM=0 ... so it will go up to 11:55PM and then go for 0:00, that is no stop – Ouki Apr 7 '14 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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