ACPI administration advocacy advocacy advocacy opinion alsa amarok apache apple apt aptitude archive audio audo authentication automount avi awk bash BIOS boot browser business cache calendar calibre cdr cdrecord censorship commandline computerscience console convert cron cut database date debian degree design desktop development disk dpkg dvd economics education emacs email europe exim faad ffmpeg file files firefox firewall flash foss freedom ftp fun fuse git gnumeric graphics grep growisofs grub gtkpod hardware hardware html icedove idiocy image imagemagick images installation ip iphone ipod iptables iso itunes ivman kde kernel keyboard knoppix lame laptop latex linux locale lockin locking longlines lsof m4a microsoft mimetypes minitab mount mp3 mp4 mplayer multimedia music mysql network nfs nfs4 nmap openbox openfiles openoffice opinion opinion orgmode partition pdf perl php podcast politics pomodoro ports postgresql printing privacy process programming rant remote rhythmbox rss rsync rxvt scp screengrab screenshot script scripting scsi security sed server services shell siteadmin sitenews sitesoftware skype skype slackware sound sox spam spreadsheet ssh statistics subversion sudo svk swap t23 t43 terminal tex text thinkpad thunderbird time timer timezone ubuntu udev upgrade usb usbmount users uuid versioncontrol vfat video vnc windows wine wordpress wordprocessing X40 xwindows xwindows youtube
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 mysql-backup.sh to mysql-backup.
Phew! It works and the script is now run weekly.
Thank you very much. This was exactly the information that I needed.
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.
I would have wasted hours on this issue. A million thanks!
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 mysql-backup.sh to mysql-backup.
Paul, thanks for this article. It saved me a lot of time and frustration.
YOU ARE FUCKING GREAT : D
i love you
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...
Thank you so much! I was just facing the same problem, and hopefully Google took me to this article.