Harsh but fair

Open source chicanery and the battle with my inner geek

Script Naming for run-parts for /etc/cron.daily

Posted by raetsel on January 19, 2010

I recently added in a new script to the directory /etc/cron.daily so it would be run once a day along with the other scripts in there but for some reason it wasn’t being run. After much messing about I discovered it was the because the name of the script had a . in it.

Specifically the script was called get_xferlog.sh as is common with shell scripts. I changed this to be just get_xferlog and that is now working ok.

The files in /etc/cron.daily are executed as part of an entry in /etc/crontab:-

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

So it uses the default settings of run-parts to execute all scripts in the directory /etc/cron.daily and the man page for run-parts says.

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.

If you want to check what run parts will do you can use the –test flag which just lists the scripts that will be executed without actually executing them. Thus

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

This proved very handy in debugging the issue I was having without having to wait a day between tests for the cron job to run.

I should add that the above applies to Ubuntu based servers,  Red Hat servers using run-parts don’t seem to care about a dot in the filename

About these ads

7 Responses to “Script Naming for run-parts for /etc/cron.daily”

  1. Matt said

    Thank you for this information. I was banging my head on my desk for 2 days trying to figure out the problem. so much to testing a *.sh script and just dropping it in the .daily folder.
    Thanks,
    Matt

  2. Markus said

    Argh. Who decided that this behaviour would be good idea, suddenly?!
    Thanks loads for this post.

  3. Raphi said

    such a stupid behaviour! ;-) just ran into it again and was looking for an explanaition.. thx for the post!

  4. blas said

    Muchas gracias por la solución. Breve y satisfactoria.

  5. Thanks! I had to use “–test” rather than “-test” which raises a complaint

    _$ run-parts -v –test /etc/cron.daily_

    Cheers!
    #plone #rsync

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

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: