systemd.cron
systemd units for cron periodic jobs
- Provided by: systemd-cron (Version: 2.8.2-1)
- Report a bug
systemd units for cron periodic jobs
cron.target
cron-update.path, cron-update.service
cron-mail@.service
These units provide the functionality usually afforded by the cron daemon — running scripts in /etc/cron.schedule directories and sending mail on failure.
Crontabs are monitored by cron-update.path
and are automatically translated by
systemd-crontab-generator(8).
You can also use this mechanism to mask an unneeded crontab
provided by a package via systemctl
mask
package.timer.
File names of crontabs in
/etc/cron.d and scripts in
/etc/cron.schedule must
consist only of ascii(7) alphanumerics, underscores
(‘_’),
and dashes (‘-’) (match the C-locale regular
expression "^[[:alnum:]_-]*$"); they will
be ignored otherwise. 0anacron and
anacron are always ignored.
cron.targetcron-update.pathcron-update.servicesystemctl
daemon-reload to re-run the generator.
cron-mail@.serviceCRON_MAIL_SUCCESS=nonempty)
for OnSuccess=),systemctl
status output, don't add usual
journalctl metadata to the output (equivalent
to
CRON_MAIL_FORMAT=nometadata),
andOverriding this via systemctl
edit can be useful, especially for units under
/etc/cron.*: set
$SENDMAIL or $MAILFROM
to override the defaults (sendmail(1) and
"root", respectively).
$SENDMAIL can be also be set from the
global systemd environment (systemctl
show-environment).
Do not use with a cron daemon or anacron, otherwise scripts may be executed multiple times.
All services are run with Type=oneshot, which means you can't use systemd-cron to launch long lived forking daemons.
Units for non-persistent jobs from
crontab(5)s are generated with sequential names, so if a
job changes (by direct editing or by removing (commenting out) a previous
job) while it is
running, and mail is sent for that job, some configuration may be
wrong (too new) and systemctl
status may be confusing. The journal output and
e-mail subject are correct. Setting
CRON_UNIQUE_UNITS
will work around this (but break existing systemctl
edit overrides).
Jobs with
PERSISTENT=true
and @-keyword are started on boot if a run was missed
while the system was off. A regular cron and anacron setup won't catch up on
the missed executions of crontabs on reboot.
Generated units log to the journal with CRON_JOB= set to the job line (systemd.journal-fields(7)).
#systemctlstartcron.target
#systemctlenablecron.target
#journalctl -u cron-daily
#systemctleditcron-geoip-database-contrib-root-1.timer
and add
[Timer] OnCalendar= OnCalendar=*-*-* 18:36:00
#systemctleditcron-daily.service
and add
[Service] CPUSchedulingPolicy=idle IOSchedulingClass=idle
[Unit] Description=Update the man db [Service] Nice=19 IOSchedulingClass=2 IOSchedulingPriority=7 ExecStart=/usr/bin/mandb --quiet [Install] WantedBy=cron-hourly.target
The exact times scripts are executed is determined by the values of the special calendar events hourly, daily, weekly, monthly, and yearly defined in systemd.time(7).
systemctl
list-timers shows an overview of current timers and
when they'll elapse.
crontab(1), systemd(1), crontab(5), systemd.service(5), systemd.timer(5), systemd.unit(5), systemd.time(7), run-parts(8), systemd-crontab-generator(8)