Backend / DevOps / Architect
Brit by birth,
located worldwide

All content © Alex Shepherd 2008-2024
unless otherwise noted

Crontab Not Running Scripts Fix

Published
1 min read
image
Image Credit: Unknown (if this is your work, reach out to me and I'll credit you!)

Hi guys!

Just a quick post this time. I came across a problem where a VM wasn't running the scripts I'd configured in its crontab. No matter what I did, run-parts just dropped straight through as if there were no scripts in cron's hourly folder. I read the man page for run-parts and found the following snippet...

the names must consist entirely of ASCII upper- and lower-case letters, ASCII digits, ASCII underscores, and ASCII minus-hyphens

My scripts were named with a .sh suffix, which meant that they had a non-specified character: the "."

I renamed them with the following script, after which, cron ran the scripts perfectly, and on time:

cd /etc/cron.hourly
for FILE in *.sh; do
    mv $FILE ${FILE/.sh/}
done

To test this, you can execute run-parts manually:

run-parts --verbose /etc/cron.hourly

In conclusion, this entire post can be shortened into 4 letters: RTFM ;-)

Anyway, just a quick one today. Feel free to leave any feedback in the comments, or via my contact page!

n00b