Linux cron tasks not executed

Some days ago have found an issue trying to execute some tasks via “cron” on my linux box, seems that cron ignores my tasks….

To execute tasks on cron you can:

  • Edit the “crontab” file for the current user (with command “crontab -e“), and put on them some tasks.

Every user allowed to execute cron tasks (take a look at /etc/cron.allow and /etc/cron.deny ) have its own crontab file with their tasks (and these tasks can be reviewed with the command “crontab -l“).

  • Also if you have root permissions you can leave the script on some of the “cron” directories under /etc:





The scripts located under these directories must be executed on the defined basis (every hour, day, week or month).


Ok, so fine, so good. I’m little lazzy, this second method seems faster and my scrip fits on one of these execution windows (is a daily script)… then I move the script to the folder /etc/cron.daily.

Some days after the scrip have no executions ¿?

After some digging have found the reason of the “no execution”… the main cron process responsible of execute the scripts inside of these folders (called “run-parts”) not like some characters on scripts names, and these “not liked” characters include “dots”, then all my scripts (ending with .sh due are shell scripts) are ignored.

After remove the extension of the scripts all began to execute on the expected time frames.

Also found that is possible to execute a “dry-run” of the “run-parts” process to check if you script is one of the candidates to be executed.

root@VirtualBox:~# run-parts --test /etc/cron.daily
root@VirtualBox:~# echo "echo HOLA" > /etc/cron.hourly/
root@VirtualBox:~# chmod 755 /etc/cron.hourly/
root@VirtualBox:~# run-parts --test /etc/cron.hourly
root@VirtualBox:~# mv /etc/cron.hourly/ /etc/cron.hourly/say_hola
root@VirtualBox:~# run-parts --test /etc/cron.hourly


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s