[SOLVED] simple cronjob in /etc/cron.hourly not working

stefan00

Member
Mar 5, 2021
9
1
23
49
I simply placed a symlink to a bash script in /etc/cron.hourly. For some reason, it is not working. The script itself works when executed manually in the shell.

It seems that run-parts is executed, but "nothing happens". Really strange for such a simple task.

What could be the issue?
 
Please share the script, its file name and the system log showing it being executed
 
Last edited:
sure :)

system log:

Code:
Jan 20 10:17:01 pve1 CRON[3377558]: pam_unix(cron:session): session opened for user root(uid=0) by root(uid=0)
Jan 20 10:17:01 pve1 CRON[3377557]: pam_unix(cron:session): session opened for user root(uid=0) by root(uid=0)
Jan 20 10:17:01 pve1 CRON[3377561]: (root) CMD (cd / && run-parts --report /etc/cron.hourly)
Jan 20 10:17:01 pve1 CRON[3377562]: (root) CMD (root^Icd / && run-parts --report /etc/cron.hourly)
Jan 20 10:17:01 pve1 CRON[3377557]: pam_unix(cron:session): session closed for user root
Jan 20 10:17:01 pve1 CRON[3377558]: pam_unix(cron:session): session closed for user root
Jan 20 10:17:01 pve1 postfix/pickup[3371019]: 3901C295A8: uid=0 from=<root>
[ . . . REMOVED . . . ]
Jan 20 10:17:01 pve1 postfix/qmgr[2442]: 3901C295A8: removed

files (simple zfs backup job):

Bash:
[root@pve1 ~]# cd /etc/cron.hourly/
[root@pve1 cron.hourly]# ls -alh
total 14K
drwxr-xr-x  2 root root   4 Jan 12 11:18 .
drwxr-xr-x 98 root root 195 Jan 19 11:31 ..
-rw-r--r--  1 root root 102 Jun 13  2025 .placeholder
lrwxrwxrwx  1 root root  37 Jan 12 11:18 run-all-backups.sh -> /opt/scripts/local/run-all-backups.sh

[root@pve1 cron.hourly]# cd /opt/scripts/local
[root@pve1 local]# ls -alh run-all-backups.sh
-rwxrwxrwx 1 root root 99 Jan 15 08:02 run-all-backups.sh

[root@pve1 local]# cat run-all-backups.sh
#!/bin/bash
/opt/scripts/local/local-backup-rpool.sh
/opt/scripts/local/local-backup-nvpool.sh

[root@pve1 local]#
 
You need to create the file/symlink in /etc/cron.* without an extension. Also make sure that all commands inside local-backup-rpool.sh and local-backup-nvpool.sh are in PATH or use absolute paths.
Test like this
Bash:
# Dry/debug run
run-parts --test /etc/cron.hourly

# Real run
run-parts /etc/cron.hourly
 
Last edited:
  • Like
Reactions: news and stefan00
Awesome - the .sh extension was the problem. Thank you :)

btw, just to make sure about PATH:

is the ENV the same for the cron job as it is on the root shell?
 
Last edited: