script in /etc/cron.daily/ does not run

I created a shell script to be run daily, and as such I placed it into /etc/cron.daily, made it executable and even restarted cron daemon, but it was still not working. After investigating cron manual, the reason was simply because the name of the script contained a dot in it! (it ended with .sh)!!!

To make sure your script gets executed, do the following:

  1. move your script into /etc/cron.daily|weekly|monthly folder
  2. make your script executable (chmod a+x /etc/<my_script_name>)
  3. rename your script so that its name contains only lower|upper case letters, digits, underscore and hyphens (=> NO DOT => no .sh or .xxx extension)
  4. ensure your script will be called by running: run-parts –test /etc/
    (it outputs the name of all script that will be called, without actually calling them => make sure the name of your script is displayed)

That’s it!
If you want to immediately run your script the way cron does, run “run-parts –verbose /etc/”


  • man cron

7 Comments: Trackback URL | Comments RSS

  1. ændrük Says:

    Very helpful.
  2. Erik Says:

    Stupid underscores messing me up! The run-parts flags -test and -verbose need to be --test and --verbose (at least they do on my machine).
  3. Erik Says:

    ^^^ Wordpress is replacing double hypens with single hypens
  4. huhu78 Says:

    Great tip! Now my cron works as expected.
  5. Anima Prava Says:

    Very useful and very clear! Thank you. ("man cron" tells it, but it is not so clear in stating that any extension MUST be avoided). There are pages and pages on the web full of "tips" that don't state this simple and MANDATORY issue (at least for me).
  6. Ludovic Urbain Says:

    Thanks, I have to say I'm disappointed in that behavior from cron.daily (run-parts whatever). Very far from following the least surprise rule at the very least. My conclusion: all cron.x are unreliable and should be avoided like the plague. crontab, on the other hand, works.
  7. pippo Says:

    The misteries of could .sh extension influence execution of a script...that's crazy!

Post a Comment

Your email is never published nor shared. You're allow to say what you want...