Why Scripts in /etc/cron.weekly Do Not Run on Debian

Scripts placed in /etc/cron.weekly on Debian do not run

* This page contains promotional content

Running on debian10(Buster), I had placed a backup script (backup.sh) under /etc/cron.weekly/, but apparently it was not running.
Of course I had given it execute permission, and I had confirmed it works when run manually.

Checking my other machines, it turned out that it works without any problem on CentOS while none of them run on Debian.

Looking into it,
according to run-parts(8), it seems that extensions containing a dot, such as .sh or .pl, do not run

$ man 8 run-parts
....
If  the  --lsbsysinit  option  is given, then the names must not end in
       .dpkg-old  or .dpkg-dist or .dpkg-new or .dpkg-tmp, and must belong  to
       one  or more of the following namespaces: the LANANA-assigned namespace
       (^[a-z0-9]+$);   the   LSB   hierarchical   and   reserved   namespaces
       (^_?([a-z0-9_.]+-)+[a-z0-9]+$);  and  the  Debian cron script namespace
       (^[a-zA-Z0-9_-]+$).

When cron runs

Incidentally, the start times for cron.daily, weekly and monthly are written in /etc/crontab

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,f
ri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --repor
t /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --repor
t /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --repor
t /etc/cron.monthly )
#

Cron logs

By default the cron log is not configured to be split out, so it is recorded in syslog

# cat /var/log/syslog | grep cron -i

That also means /var/log/cron.log is not created. If you want to split it out as cron.log, uncomment the cron line in rsyslog.conf

# vim /etc/rsyslog.conf
cron.*                          /var/log/cron.log

# systemctl restart rsyslog

These notes are about the situation on Debian10, but the same may well apply to Ubuntu, which is in the same family

See also