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

I want my projectors to Power On before the mall opens, and Power Off when the mall closes. So I created crontab entries (that I placed in /etc/cron.d/mall), but today (Thu Nov 22 18:58:29 EST 2012 is the current date on that server), the power-off.sh script got executed at 17:20 (see syslog excerpt below).

Being Thu, Nov. 22, I would have expected the power-off.sh script to be executed at 21:20, per the 4th crontab line below.

Why did power-off.sh execute at 17:20? What is wrong with my crontab entries?

Content of /etc/cron.d/mall:

40  9 22-30 Nov Mon-Sat myuser /usr/local/projectors/power-on.sh
40 10 22-30 Nov Sun     myuser /usr/local/projectors/power-on.sh

20 18 22-30 Nov Mon-Wed myuser /usr/local/projectors/power-off.sh
20 21 22-30 Nov Thu-Fri myuser /usr/local/projectors/power-off.sh
20 17 22-30 Nov Sat-Sun myuser /usr/local/projectors/power-off.sh

40  9  1-22 Dec Mon-Sat myuser /usr/local/projectors/power-on.sh
40 10  1-22 Dec Sun     myuser /usr/local/projectors/power-on.sh

20 21  1-22 Dec Mon-Fri myuser /usr/local/projectors/power-off.sh
20 17  1-22 Dec Sat-Sun myuser /usr/local/projectors/power-off.sh

syslog excerpt:

$ grep power-off.sh /var/log/syslog
Nov 22 17:20:01 lanner-ubu-c2d CRON[23007]: (myuser) CMD (/usr/local/projectors/power-off.sh)
share|improve this question
1  
You aren't opening the mall ungodly early on Black Friday? :) –  Michael Hampton Nov 23 '12 at 0:48
    
eheh. A good point, but living in Canada, we're not really touched by all this madness! –  Guillaume Boudreau Nov 23 '12 at 2:03

2 Answers 2

My best guess would be that it can't handle Sat-Sun because of this in the man page of crontab(5):

Names can also be used for the ``month'' and ``day of week'' fields.   Use
the  first three letters of the particular day or month (case doesn't mat‐
ter).  Ranges or lists of names are not allowed.

This means some of your lines are simply incorrect and will probably cause unexpected or at least undocumented behaviour.

Therefore, I suggest to change you day of week limits to numbers.

share|improve this answer
    
Superb. Thanks. I think I saw that paragraph many times, but never bothered to read the end! –  Guillaume Boudreau Nov 23 '12 at 2:02
up vote 0 down vote accepted

From crontab(5) man page:

Note: The day of a command's execution can be specified by two fields day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time. For example, 30 4 1,15 * 5 would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.

share|improve this answer

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.