
On Mon, Jul 26, 2021 at 10:17:08AM -0400, Neal Gompa wrote:
On Mon, Jul 26, 2021 at 10:13 AM Jan Engelhardt <jengelh@inai.de> wrote:
On Monday 2021-07-26 11:21, Danilo Spinella wrote:
run-parts program from debian seems reliable and well-written. However, the crontab needs to be updated to use it:
01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly
If that is all we need to do, then
42 4 1 * * root for i in /etc/cron.monthly/*; do [ -x "$i" ] && [ -f "$i" ] && "$i"; done
might just be as sufficient, not requiring debianutils.
On the other hand, this would be an opportunity for systemd to just automatically scan those directories, similar to what systemd-fstab-generator does with /etc/fstab.
I am a little surprised that we don't have a generator for cron to systemd timers. Is there a particular reason we don't have that?
The most obvious reason is that somebody would have to write it, and so far nobody has, afaik. But there's also the consideration that crond/anacron/cronie/… have various additional functionality like automatic sending of mails, custom reporting, etc. I think that the thinking was that people who use cron might want to have those things, and will be happier using cron than trying to provide similar-but-different functionality using systemd. The cost of running a cron daemon is pretty low, so there didn't seem to be any pressing need to move. One particular feature that works quite differently is user tasks: with cron the user can just schedule tasks. With systemd, the user session provides equivalent functionality, but only when it's active. Lingering allows user tasks without a session, but it has other effects and is a more heavy-weight solution. We generally think that tasks that were often handled using a user crontab entry should instead be converted to a system unit with User=…. The summary is: the functionality is somewhat different, and having cron in parallel to systemd timers is not a problem. If somebody wants to investigate various options and provide some converter, I expect it would be useful to some people, but it's not trivial and some people will not be happy with the changes. Zbyszek