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:
- move your script into /etc/cron.daily|weekly|monthly folder
- make your script executable (chmod a+x /etc/cron.xxx/<my_script_name>)
- rename your script so that its name contains only lower|upper case letters, digits, underscore and hyphens (=> NO DOT => no .sh or .xxx extension)
- ensure your script will be called by running: run-parts –test /etc/cron.xxx/
(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/cron.xxx”
sources
- man cron

