Score:0

Why can cronjob and systemd not work together?

cn flag

I want to auto renew the certbot certificate. I came across the following auto generated file but it says:

This cronjob will NOT be executed if you are running systemd as your init system.

I am using systemd for automatically restarting some other services in case of crash/system restart. So I'm assuming that above quote applies to me.

What is the reason that the cronjob won't run when systemd is used as the init system? Can systemd and cronjob not be used together?

# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc.  Renewal will only occur if expiration
# is within 30 days.
#
# Important Note!  This cronjob will NOT be executed if you are
# running systemd as your init system.  If you are running systemd,
# the cronjob.timer function takes precedence over this cronjob.  For
# more details, see the systemd.timer manpage, or use systemctl show
# certbot.timer.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew
hr flag
It looks like it is *designed* not to run if systemd is the init system (the test `! -d /run/systemd/system` will fail) - presumably because the cron job is unnecessary in that case
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.