Productive Linux


 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Don't have an account?
Sign up to
Forgot your password?

Cron, run-parts and script names
12 March 2006 @ 23:57 GMT
by Paul

You've written a great little script. You've put in in /etc/cron.weekly so that it will get run every week. You wait until you're sure a week has passed and then check to see whether the script has run. It hasn't. You run it manually to test it. It works.

You wait another week. Once again the script hasn't run. You wonder what is wrong with your script? You google and find something like this which doesn't apply. You feel like pulling your hair out in frustration.

You have a look at your system's crontab:

# m h dom mon dow user  command
17 *    * * *   root    run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6    * * 7   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6    1 * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly

Hourly scripts are run at 17 minutes past the hour, daily scripts at 06.25 everyday, weekly ones at 06.47 on Sundays and monthly ones at 06.52 on the first day of the month. So why isn't your script running?

You see that it is run using run-parts. You check the man page for run-parts and you notice that there is a '--test' option that just prints the name of scripts to be run. You try it on your script. Your script isn't listed. Why does run-parts hate your script so much?

You scan down the man page. It says:

If the --lsbsysinit option is not given then the names must consist entirely of upper and lower case letters, digits, underscores, and hyphens.

Your read it again carefully. Upper and lower case letters, digits, underscores and hyphens doesn't include dots. But you've included a dot in your script. You always do, don't you?. After all, shell scripts always end in '.sh'. Right?

Well, not when they're run by run-parts. So, you change the name of your script from to mysql-backup.

Phew! It works and the script is now run weekly.

Learn Shell Scripting

Thank you very much. This was exactly the information that I needed.

Posted by Guest User on 2006-11-13 17:40:29.

Snap! Except you had that solution bit as well.
Nice article. ;?)

...and I mention that I notice Kubuntu (Dapper), has its
locatedb cron script b0rked by default because of this "issue"
with run-parts...erm, because that might be interesting too? heh.

Again, thanks.


Posted by Guest User on 2006-10-06 16:29:16.

I would have wasted hours on this issue. A million thanks!

Posted by Guest User on 2008-03-04 15:51:11.

Thanks! lol. It was kind of freaky -- that was *exactly* what i went through.

You just need to change the second last paragraph: Well, not when they're run by run-parts. So in frustration/bewilderment you continue googling and come across this site. After reading "Well, not when they're run by run-parts" you change the name of your script from to mysql-backup.

Posted by andrew on 2009-03-10 08:54:57.

Paul, thanks for this article. It saved me a lot of time and frustration.

Posted by Mis Tigi on 2010-07-28 02:46:37.


i love you

Posted by Marco on 2010-10-14 08:16:48.

it would be nice if run-parts could detect files in a designated directory and tell the user they cannot be executed. that at least gives you a starting point...

Posted by asdf on 2011-03-21 14:10:10.

Thank you so much! I was just facing the same problem, and hopefully Google took me to this article.

Posted by Electrocut on 2012-07-23 18:48:47.
Comments disabled