Re: [PATCH v3 4/4] maintenance: optionally use systemd timers on Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21/05/21 05.13, Lénaïc Huard wrote:
The existing mechanism for scheduling background maintenance is done
through cron. On Linux systems managed by systemd, systemd provides an
alternative to schedule recurring tasks: systemd timers.

The main motivations to implement systemd timers in addition to cron
are:
* cron is optional and Linux systems running systemd might not have it
   installed.
* The execution of `crontab -l` can tell us if cron is installed but not
   if the daemon is actually running.
* With systemd, each service is run in its own cgroup and its logs are
   tagged by the service inside journald. With cron, all scheduled tasks
   are running in the cron daemon cgroup and all the logs of the
   user-scheduled tasks are pretended to belong to the system cron
   service.
   Concretely, a user that doesn’t have access to the system logs won’t
   have access to the log of its own tasks scheduled by cron whereas he
   will have access to the log of its own tasks scheduled by systemd
   timer.

For gender neutrality, we can use he/she instead.

   Although `cron` attempts to send email, that email may go unseen by
   the user because these days, local mailboxes are not heavily used
   anymore.

In order to schedule git maintenance, we need two unit template files:
* ~/.config/systemd/user/git-maintenance@.service
   to define the command to be started by systemd and
* ~/.config/systemd/user/git-maintenance@.timer
   to define the schedule at which the command should be run.

Those units are templates that are parameterized by the frequency.

Based on those templates, 3 timers are started:
* git-maintenance@hourly.timer
* git-maintenance@daily.timer
* git-maintenance@weekly.timer

The command launched by those three timers are the same as with the
other scheduling methods:

git for-each-repo --config=maintenance.repo maintenance run
--schedule=%i

with the full path for git to ensure that the version of git launched
for the scheduled maintenance is the same as the one used to run
`maintenance start`.


Wouldn't it be `/path/to/git for-each-repo <options>...`?

The timer unit contains `Persistent=true` so that, if the computer is
powered down when a maintenance task should run, the task will be run
when the computer is back powered on.


The title for this patch implied that users running Linux can choose
between classic crontab or systemd timers. However, the intent of this
patch is we add support for systemd timers. So let's say the title
should be "maintenance: add support for systemd timers on Linux".

--
An old man doll... just what I always wanted! - Clara



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux