0

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!

11
  • 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, 2012 at 14:22
  • Yes and yes and no.
    – Alex
    Mar 28, 2012 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, 2012 at 14:25
  • Thank you - I tried this before. Unfortunately with no success. Cron can really be a beast sometimes... :/
    – Alex
    Mar 28, 2012 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, 2012 at 14:33

3 Answers 3

2

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.

1
  • 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, 2012 at 9:43
1

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.

3
  • 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, 2012 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, 2012 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, 2012 at 9:43
1

You are missing the user portion of the cron job.

0 12 * * * root /bin/sh /root/backup
4
  • 1
    crontab -e edit's the users crontab file which doesn't require a username to be specified.
    – user9517
    Mar 28, 2012 at 17:52
  • @Alex: I think hasan may be right. I duplicated same behavior with my Dev box.
    – Magellan
    Mar 28, 2012 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, 2012 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, 2012 at 9:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .