Score:0

Why does my crontab not run cron.daily scripts?

cn flag

My crontab file is in /etc/
I have a folder: /etc/cron.daily with dbBackup_sh, logrotate and tmpreaper
I run these 3 scripts manually every day with no problem.

My crontab will not run the daily scripts.
What is wrong with my crontab file?

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
23 * * * * root cd / && run-parts --report /etc/cron.hourly
1 4 * * * root  cd / && run-parts --report /etc/cron.daily
48 3 * * 7 root cd / && run-parts --report /etc/cron.weekly
25 3 8 * * root cd / && run-parts --report /etc/cron.monthly

Output of ls -la /etc/cron.daily/:

-rw-r--r-- 1 root root 102 Feb 22 2021 .placeholder 
-rw-r--r-- 1 root root 449 Mar 29 2022 dbBackup_sh 
-rwxr-xr-x 1 root root 377 Feb 28 2021 logrotate 
-rwxr-xr-x 1 root root 4006 Sep 6 2019 tmpreaper 
Pilot6 avatar
cn flag
Can you post contents of `cron.daily` and your scripts?
Artur Meinild avatar
vn flag
Yes please include the output of `ls -la /etc/cron.daily/` in your question.
hr flag
... there are also naming conventions for `run-parts` (in particular, no "dot extensions" iirc)
terdon avatar
cn flag
@steeldriver it's considerably more complex. It never made sense to me: [How do you use the run-parts command?](https://superuser.com/a/719493)
Score:2
vn flag

The scripts inside /etc/cron.daily/ has to be executable to run. (This has the additional benefit, that if you want to temporarily disable a cron job here, just unset the executable bit for that particular script.)

One of your files (dbBackup_sh) does not have the executable bit set. Fix this with:

sudo chmod +x /etc/cron.daily/dbBackup_sh

Also, as @steeldriver mentions, the names must only include alphanumeric characters, dash (-) and underscore (_) - which is also the case for you.

To me, it would seem all scripts will run after you fix permissions for dbBackup_sh.

A good way to test if a cron script has been running is to include a line that touches a file. You could add to each script: (The variable $0 expands to the script name.)

touch "/dev/shm/${0##*/}"

Then, look inside the folder /dev/shm tomorrow, and check if the files are there.

uz flag
Jos
You will be able to verify that that was the problem by looking in `/var/log/syslog`.
kristy1024 avatar
cn flag
I see, yes x is missing. I just fixed that as you suggested. We'll see what happens tomorrow. Thank You.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.