8

I have a bash script foo.sh located in the /etc/cron.daily directory, chmoded 700, owned by root, crontab list for the root user is unchanged (crontab -l) from the core Debian installation. I did run cronjob in another way than crontab -l and/or crontab -e (eg I did not restart cron daemon with /etc/init.d/cron as adviced in the specific Debian's case). Despite a test job file is running under similar conditions. The script is debugged and can be run as a standalone task without returning errors. I've also checked logs (/var/log/syslog) and nothing wrong in there.

But: this particular job is not executed at all.

hornetbzz
  • 9,188
  • 5
  • 36
  • 53

3 Answers3

14

Oops. Guess I found the "why" or at least, the "how" :

Only renaming the job filename without ".sh" extension solved that issue.

I thought it was a Debian's bug but it isn't, as described in the other answers below.

SOLUTION: rename your script by removing all . or + characters from its name

hornetbzz
  • 9,188
  • 5
  • 36
  • 53
  • 1
    It is specific to debian. It's not a bug, as far as they are concerned. – Glen Solsberry Mar 30 '11 at 13:03
  • 1
    @gms8994: thx, but I did not find anywhere this point about job filenames. I found it on purpose, making dichotomial tests. – hornetbzz Mar 30 '11 at 13:07
  • 2
    I found it the same way; see [my question](http://serverfault.com/questions/99584/not-all-cron-jobs-in-etc-cron-daily-are-running) for more information. – Glen Solsberry Mar 30 '11 at 13:13
9

the /etc/cron.daily scripts are executed by run-parts (see man 8 run-parts).

there you go with a snip from the manpage:

If neither the --lsbsysinit option nor the --regex option is given then the names must consist entirely of upper and lower case letters, digits, underscores, and hyphens.

from /etc/crontab you can see that the daily cron jobs are being run with:

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

debian doesn't use anacron and there's no --lsbsysinit option specified for run-parts (in that case '.' will be accepted in the cron script filename as per the LSB hierarchical and reserved namespaces)

anyway, to make sure cron will run your script you can always run run-parts and check that your script is listed in the run-parts output:

run-parts --test /etc/cron.daily

or

run-parts --list /etc/cron.daily

I hope my comment helps you understand what the real problem was.

user237419
  • 8,829
  • 4
  • 31
  • 38
0

All the answers given before are good and acceptable to the question. However, I believe I should add my point as well to make it clear, that Debian Linux OS does not support cron job filenames that include the . or + character. See the relevant section in the Debian Policy Manual.

So this is just to avoid confusion, that it's not a bug. That's how Debian works.

slugster
  • 49,403
  • 14
  • 95
  • 145
miklosq
  • 95
  • 5
  • Hi slugster, thanks for the effort editing. It does not really matter for me how it is called 'period' or 'dot' or nothing at all. For me, it means the same. Now it's clear just by reading the sign. – miklosq Mar 03 '14 at 11:11