A surprise with /etc/cron.daily, run-parts, and files with '.' in their name

October 15, 2024

Linux distributions have a long standing general cron feature where there is are /etc/cron.hourly, /etc/cron.daily, and /etc/cron.weekly directories and if you put scripts in there, they will get run hourly, daily, or weekly (at some time set by the distribution). The actual running is generally implemented by a program called 'run-parts'. Since this is a standard Linux distribution feature, of course there is a single implementation of run-parts and its behavior is standardized, right?

Since I'm asking the question, you already know the answer: there are at least two different implementations of run-parts, and their behavior differs in at least one significant way (as well as several other probably less important ones).

In Debian, Ubuntu, and other Debian-derived distributions (and also I think Arch Linux), run-parts is a C program that is part of debianutils. In Fedora, Red Hat Enterprise Linux, and derived RPM-based distributions, run-parts is a shell script that's part of the crontabs package, which is part of cronie-cron. One somewhat unimportant way that these two versions differ is that the RPM version ignores some extensions that come from RPM packaging fun (you can see the current full list in the shell script code), while the Debian version only skips the Debian equivalents with a non-default option (and actually documents the behavior in the manual page).

A much more important difference is that the Debian version ignores files with a '.' in their name (this can be changed with a command line switch, but /etc/cron.daily and so on are not processed with this switch). As a non-hypothetical example, if you have a /etc/cron.daily/backup.sh script, a Debian based system will ignore this while a RHEL or Fedora based system will happily run it. If you are migrating a server from RHEL to Ubuntu, this may come as an unpleasant surprise, partly since the Debian version doesn't complain about skipping files.

(Whether or not the restriction could be said to be clearly documented in the Debian manual page is a matter of taste. Debian does clearly state the allowed characters, but it does not point out that '.', a not uncommon character, is explicitly not accepted by default.)


Comments on this page:

By loreb at 2024-10-21 07:18:13:

This REALLY took me by surprise since I aside from debian I use void-linux, which uses cronie... except with debian's run-parts it seems (https://github.com/void-linux/void-packages/blob/master/srcpkgs/cronie/template)

I no longer remember when I found out; nowadays my typical (as upstream intended?) usage is to temporarily disable a script, as in

mv myscript myscript.off

or maybe "no", "disabled", etc etc

Written on 15 October 2024.
« We have lots of local customizations (and how we keep track of them)
Our various different types of Ubuntu installs »

Page tools: View Source, View Normal.
Search:
Login: Password:

Last modified: Tue Oct 15 23:30:11 2024
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.