This is a compatibility layer for crontab-to-systemd timers framework. It works by parsing
crontab and anacrontab files from usual places like
and generating systemd timers and services. You can use
cron.target as a single control
point for the generated units.
It's intended to be a drop-in replacement for all cron implementations.
I am not convinced this is a really good idea. From my perspective at least it appears that we should much rather just convert the crontabs and that's it. Unlike sysv init scripts the number of crontab in use (at least on Fedora) is relatively small, and very rare in third-party packages.
While I generally agree with him, I'm not totally convinced it's always convenient to herd a bunch of
*.service files. I find convenient to have all jobs schedule in one single file,
and it's more obvious to see relations in jobs scheduling if you have several jobs in sight at once.
All things considered, I think people should have an alternative here, so I decided to support
the idea of systemd crontab generator. Though the original C implementation of crontab parser
from maillist is very incomplete: it doesn't support monotonic schedules (like
it can't parse comments and environment variable settings, etc.
Hence, I decided to create systemd-crontab-generator.
I'm not very good in C, so C implementation (while it's recommended for generators) whould take me ages to write, so at first, I used Python for proof-of-concept implementation. Then my small home project was noticed by @systemd-cron project and eventually was merged into it and evolved thanks to Alexandre Detiste, Dwayne Bent and others.
Still I bore in mind the image of the project's future: rewrite it in a systems language. Python, being VM-based scripting language is not the best choice for system service: it's slow (the slowest systemd generator ever, actually), have problems with multithreading, requires a lot of hacks like setgid/setuid C helper to implement crontab, etc.
The current version you are looking at is meant to be a successor of @systemd-cron The project, entirely rewritten in Rust from ground up, while preserving experience, systemd unit templates and main algorithms and solutions polished in Python version by @systemd-cron team.
The generator runs on system boot and when the crontabs change.
The project includes simple
crontab command equivalent, which behaves like standard crontab command
(and accepts the same main options).
After installation add executable scripts to the appropriate cron directory (e.g.
and enable systemd-cron:
# systemctl daemon-reload # systemctl enable cron.target # systemctl start cron.target
The scripts should now be automatically run by systemd. See man:systemd.cron(7) for more information.
To further control cron jobs, use
- systemd ≥ 197
- systemd ≥ 209, yearly timers
- systemd ≥ 212, persistent timers
- systemd ≥ 217, minutely, quarterly & semi-annually timers
- systemd ≥ 229, real random delay support with
- /usr/sbin/sendmail (optional, evaluated at runtime)
$ ./configure $ make
You will need Rust stable compiler (tested with 1.5.0) and cargo tool to build the project.
$ make DESTDIR="$destdir" install
configure script takes command line arguments to configure various details of the build. The following options
follow the standard GNU installation directories:
Other options include:
--unitdir=<path>Path to systemd unit files. Default:
--runpaths=<path>The path installations should use for the
--enable-boot[=yes|no]Include support for the boot timer. Default:
--enable-minutely[=yes|no]Include support for the minutely timer. Requires systemd ≥ 217. Default:
--enable-hourly[=yes|no]Include support for the hourly timer. Default:
--enable-daily[=yes|no]Include support for the daily timer. Default:
--enable-weekly[=yes|no]Include support for the weekly timer. Default:
--enable-monthly[=yes|no]Include support for the monthly timer. Default:
--enable-quarterly[=yes|no]Include support for the quarterly timer. Requires systemd ≥ 217. Default:
--enable-semi_annually[=yes|no]Include support for the semi-annually timer. Requires systemd ≥ 217. Default:
--enable-yearly[=yes|no]Include support for the yearly timer. Requires systemd ≥ 209. Default:
--enable-persistent[=yes|no]Make timers persistent. Requires systemd ≥ 212. Default:
RANDOM_DELAYsupport. Requires systemd ≥ 229. Default:
A typical configuration for the latest systemd would be:
$ ./configure --prefix=/usr --confdir=/etc --enable-yearly --enable-persistent
If you only want the generator (you'll have to provide your own
/etc/crontab to drive /etc/cron.daily/ etc...):
$ ./configure --enable-boot=no --enable-hourly=no --enable-daily=no --enable-weekly=no --enable-month=no --enable-persistent --prefix=/usr --confdir=/etc
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
This is a beta product! Use at your risk! I'm not responsible for any data losses, time losses, money losses or any other failures due to use or misuse of this project! I've run this product on my local server for several months without issues, but it does not mean you will have no issues as well! Don't blame me for any crashes because of the product! You were warned!
Original @systemd-cron project:
- © 2013-2014 Dwayne Bent
- © 2013 Dominik Peteler
- © 2014 Daniel Schaal email@example.com
Systemd crontab generator evolution, tooling, and support:
- © 2014 Alexandre Detiste firstname.lastname@example.org
- © 2014 Dwayne Bent
Original systemd crontab generator code in Python, Rust version:
- © 2014-2015 Konstantin Stepanov email@example.com
Systemd crontab generator man-page (man/systemd-crontab-generator.8.in):
- © 2014 Alexandre Detiste firstname.lastname@example.org
Crontab man-page (man/crontab.5.in):
- © 1988, 1990, 1993, 1994, Paul Vixie email@example.com
- © 1994, Ian Jackson firstname.lastname@example.org
- © 1996-2005, Steve Greenland email@example.com
- © 2005-2006, 2008-2012, Javier Fernández-Sanguino Peña firstname.lastname@example.org
- © 2010-2011, 2014 Christian Kastner email@example.com
- Numerous contributions via the Debian BTS copyright their respective authors