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 have a strange problem. Using Debian 6 and crontab -e (as root),the following cronjob works just fine:

 */5 * * * * bin/sh /root/backup

but it does not work if I set it to run at a specific time:

 00 12 * * * bin/sh /root/backup

Unfortunately, there is no error at all in the logfiles.

 date

shows the correct time and timezone.

I have also changed UTC to "no" instead of "yes" in /etc/default/rcS, but that did not help.

I am totally clueless what the reason might be and hope that you may have a solution for me!

share|improve this question
    
You had the crontab saved by 12:00 on your timezone? /var/log/cron didn't show any errors at all? Or did it show that the task had been run? –  AliGibbs Mar 28 '12 at 14:22
    
Yes and yes and no. –  Alex Mar 28 '12 at 14:23
    
Instead of 00 12 * * * bin/sh /root/backup can you try: 0 12 * * * bin/sh /root/backup (or a time very shortly, just a single digit rather than 2) –  AliGibbs Mar 28 '12 at 14:25
    
Thank you - I tried this before. Unfortunately with no success. Cron can really be a beast sometimes... :/ –  Alex Mar 28 '12 at 14:27
    
Hrm ok, put this script in /etc/cron.d/ does it run then? or do you have any system crons setup? In /etc/cron.d/daily etc? do these run/log? –  AliGibbs Mar 28 '12 at 14:33

3 Answers 3

As has already been mentioned, make sure there is an empty line at the end of the file. I would also not use bin/sh but use the absolute path (/bin/sh).

What could be the issue (which if there is no error could be considered a bug) is the fact that you're specifying 00 rather than 0. The specification for time (taken from the man page) is:

The time and date fields are:

          field          allowed values
          -----          --------------
          minute         0-59
          hour           0-23
          day of month   1-31
          month          1-12 (or names, see below)
          day of week    0-7 (0 or 7 is Sun, or use names)

Note that there they are specifying a single digit 0.

share|improve this answer
    
Well, well... :-( I have tried EVERYTHING. Thank you all for your appreciated help. Unfortunately, it did not work out. I have wiped the server and installed CentOS instead. Cron works fine now and as Debian is not really necessary on that server, I will simply stick with CentOS. Again, thank you all! –  Alex Mar 29 '12 at 9:43

Make sure that the line with the specific date is not the last line in your crontab. Vixie cron still had a bug about all crontab lines needing a linefeed to work properly last time I checked.

Perhaps a comment at the end would suffice.

share|improve this answer
    
Thank you - I have double checked this. There is an empty line at the end of the crontab... Still it does not work. :-/ –  Alex Mar 28 '12 at 14:03
    
Judging by all the comments above, I'd be thinking about running strace on the crond process and see what it's doing at the time point where it's supposed to kick off. –  Magellan Mar 28 '12 at 14:55
    
Well, well... :-( I have tried EVERYTHING. Thank you all for your appreciated help. Unfortunately, it did not work out. I have wiped the server and installed CentOS instead. Cron works fine now and as Debian is not really necessary on that server, I will simply stick with CentOS. Again, thank you all! –  Alex Mar 29 '12 at 9:43

You are missing the user portion of the cron job.

0 12 * * * root /bin/sh /root/backup
share|improve this answer
1  
crontab -e edit's the users crontab file which doesn't require a username to be specified. –  Iain Mar 28 '12 at 17:52
    
@Alex: I think hasan may be right. I duplicated same behavior with my Dev box. –  Magellan Mar 28 '12 at 17:57
1  
If you do crontab -e as root you don't need the user part. This is how all our crons are at work. –  webtoe Mar 29 '12 at 7:19
    
Well, well... :-( I have tried EVERYTHING. Thank you all for your appreciated help. Unfortunately, it did not work out. I have wiped the server and installed CentOS instead. Cron works fine now and as Debian is not really necessary on that server, I will simply stick with CentOS. Again, thank you all! –  Alex Mar 29 '12 at 9:44

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.