systemd units to run cron scripts
systemd units to provide cron daemon functionality by running scripts in cron directories.
The crontabs are automaticaly translated using /usr/lib/systemd/system-generators/systemd-crontab-generator.
Add executable scripts to the appropriate cron directory (e.g. /etc/cron.daily
) and enable systemd-cron:
# systemctl daemon-reload
# systemctl enable cron.target
# systemctl start cron.target
The project also includes simple crontab command equivalent, which behaves like standard crontab command (and accepts the same main options).
The scripts should now be automatically run by systemd. See man:systemd.cron(7) for more information.
- systemd ≥ 236
- python ≥ 3.9
- UsrMerged system
- run-parts (optional)
- /usr/sbin/sendmail (optional, evaluated at runtime)
- gcc or clang (needed to build
crontab_setgid.c
; this helper is optional and evaluated at runtime) - support for /usr/lib/sysusers.d/*.conf (optional)
- systemd ≥ 197, first support for timers
- systemd ≥ 209, yearly timers
- systemd ≥ 212, persistent timers
- systemd ≥ 217, minutely, quarterly & semi-annually timers
- systemd ≥ 229, real random delay support with
RandomizedDelaySec
option (bug) - systemd ≥ 236,
LogLevelMax
option
There exists packages avaible for:
There is also a old .spec file for Fedora in contrib/.
A complete list of all packages can be browsed at Repology.
You can also build it manually from source.
$ ./configure
$ make
$ make DESTDIR="$destdir" install
The configure
script takes command line arguments to configure various details of the build. The following options
follow the standard GNU installation directories:
--prefix=<path>
--bindir=<path>
--datadir=<path>
--libdir=<path>
--libexecdir=<path>
--statedir=<path>
--mandir=<path>
--docdir=<path>
Other options include:
--unitdir=<path>
Path to systemd unit files. Default:<libdir>/systemd/system
.--enable-boot[=yes|no]
Include support for the boot timer. Default:yes
.--enable-minutely[=yes|no]
Include support for the minutely timer. Default:no
.--enable-hourly[=yes|no]
Include support for the hourly timer. Default:yes
.--enable-daily[=yes|no]
Include support for the daily timer. Default:yes
.--enable-weekly[=yes|no]
Include support for the weekly timer. Default:yes
.--enable-monthly[=yes|no]
Include support for the monthly timer. Default:yes
.--enable-quarterly[=yes|no]
Include support for the quarterly timer. Default:no
.--enable-semi_annually[=yes|no]
Include support for the semi-annually timer. Default:no
.--enable-yearly[=yes|no]
Include support for the yearly timer. Default:no
.--enable-setgid[=yes|no]
Compile setgid C helper for crontab. Needs GCC or Clang. Default:no
.
A typical configuration for the latest systemd would be:
$ ./configure
(the default settings are a common ground between what is seen on current Arch/Debian/Gentoo packaging)
Alternatively you can also generate individual .timer/.service for all the jobs in /etc/cron.{hourly,daily,weekly,monthly,...}:
$ ./configure --enable-runparts=no
Your package should also run these extra commands before starting cron.target to ensure that @reboot scripts doesn't trigger right away:
# touch /run/crond.reboot
# touch /run/crond.bootdir
systemd.cron(7)
or in source tree man -l src/man/systemd.cron.7
The project is licensed under MIT.
© 2014, Dwayne Bent : original package with static units
© 2014, Konstantin Stepanov (me@kstep.me) : author of crontab generator
© 2014, Daniel Schaal : review of crontab generator
© 2014, Alexandre Detiste (alexandre@detiste.be) : manpage for crontab generator