Why cron does not run cron.hourly/daily/weekly/monthly scripts?

Your scripts in /etc/cron.hourly/, /etc/cron.daily/, /etc/cron.weekly/, or /etc/cron.monthly/ do not run?
The problem is: if your script contains “dot”, e.g. when the file name contains extension (script.sh), the script is not run by run-parts.
So, all you have to really do is rename the script, or put a extension-less symlink to the script in the folder.

The reason is “bug” in run-parts, that run-parts fails silently on such files.
run-parts is used by cron to execute scripts in the /etc/cron.xxx directories – take a look at /etc/crontab file, it contains lines with: run-parts --report /etc/cron.hourly.

This is not really a bug, see man run-parts, but the description is not the clearest:

    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.

You can always edit the /etc/crontab file, to include the --regex option for more general file names, but imo it’s easier to just get rid of the extension… 😉

6 responses to “Why cron does not run cron.hourly/daily/weekly/monthly scripts?

  1. Thank you, JC!

    There is meaning, btw. Only a relative, very human meaning. Anything more could only mean less to the human animal.

  2. Pingback: CRON: A script in cron.daily folder is not executed (Fix) | Void Technology

  3. Pingback: Joseph's Web Log » /etc/cron.{hourly,daily,weekly,monthly} 裡頭的 scripts 不能有副檔名

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s