[Solved] cron.daily scripts not running

Am i right in thinking that If i put a script in /etc/cron.daily then it will be run once a day? Is there anything else I need to do to enable this because i have 2 scripts in there (user:group set to root and chmod +x on both) but neither of them run. I tried moving them to /etc/cron.minutely with no joy either.

Am I missing a step?


Please verify, that your scripts do not contain any syntax error and contain #!/bin/bash as first line and the result is as expected.

bash /etc/cron.daily/your_script

Cron calls the scripts via run-parts command, you can also check that your scripts are handled by this, by checking if the following output contains them:

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

Finally, if this works, but cron does still not execute them, verify that /etc/crontab actually contains the needed line and is not broken somehow:
cat /etc/crontab
Result should be (with possible adjusted times via dietpi-cron):

root@DietPi:~# cat /etc/crontab
#Please use dietpi-cron to change cron start times

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

dietpi-cron can be used to adjust times and regenerate/fix /etc/crontab in case.

1 Like

Thanks so much for your help.

The scripts are fine and run correctly with:

bash /etc/cron.daily/mikrotik-clean.sh

Running the command below, as you suggested, doesn’t show my scripts in the output. Any idea why this could be?

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

Also /etc/crontab contains the needed lines.

Thanks for your help.

OK I know where the issue is. Thanks for the guidance MichaIng, it helped.

What I didn’t realise was that run-parts doesn’t like periods. My scripts had the extension .sh Once I removed that all was fine.

Thank you

Ah great and good to know, would have been my last guess, based on the fact that non of the other scripts contain file endings.

Because you mentione run-parts I did some investigating and found this which made me realise:

Thanks again

1 Like