I used the command below to see the certbot timer since I was told that on machines with systemd (like Ubuntu) the cron setting is not used…
It resulted in this almost incomprehensible output:
$ sudo systemctl show certbot.timer
Unit=certbot.service
NextElapseUSecRealtime=Sun 2019-12-29 02:02:22 CET
NextElapseUSecMonotonic=0
LastTriggerUSec=Sat 2019-12-28 19:41:41 CET
LastTriggerUSecMonotonic=3w 6h 29min 52.366125s
Result=success
AccuracyUSec=1min
RandomizedDelayUSec=12h
Persistent=yes
WakeSystem=no
RemainAfterElapse=yes
Id=certbot.timer
Names=certbot.timer
Requires=sysinit.target -.mount
WantedBy=timers.target
Conflicts=shutdown.target
Before=timers.target certbot.service shutdown.target
After=time-sync.target -.mount sysinit.target
Triggers=certbot.service
RequiresMountsFor=/var/lib/systemd/timers
Description=Run certbot twice daily
LoadState=loaded
ActiveState=active
SubState=waiting
FragmentPath=/lib/systemd/system/certbot.timer
UnitFileState=enabled
UnitFilePreset=enabled
StateChangeTimestamp=Sat 2019-12-28 19:41:49 CET
StateChangeTimestampMonotonic=1837800267414
InactiveExitTimestamp=Sat 2019-12-07 13:12:11 CET
InactiveExitTimestampMonotonic=22723336
ActiveEnterTimestamp=Sat 2019-12-07 13:12:11 CET
ActiveEnterTimestampMonotonic=22723336
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=no
NeedDaemonReload=no
JobTimeoutUSec=infinity
JobRunningTimeoutUSec=infinity
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Sat 2019-12-07 13:12:11 CET
ConditionTimestampMonotonic=22723287
AssertTimestamp=Sat 2019-12-07 13:12:11 CET
AssertTimestampMonotonic=22723287
Transient=no
Perpetual=no
StartLimitIntervalUSec=10s
StartLimitBurst=5
StartLimitAction=none
FailureAction=none
SuccessAction=none
InvocationID=824d304e75b54c78847f3ddd90e18ce1
CollectMode=inactive
Please tell me how to get rid of this “timer” and associated “service” so I can use my simple to understand cron job (for sudo).
I do not want to have something running with the wrong certbot version and in a way that I cannot understand either.
EDIT:
I have now found where the certbot.timer and certbot.service files reside.
They are in /lib/systemd/system/ as
certbot.timer and certbot.service respectively.
Content is:
certbot.timer:
--------------------------------------------
[Unit]
Description=Run certbot twice daily
[Timer]
OnCalendar=*-*-* 00,12:00:00
RandomizedDelaySec=43200
Persistent=true
[Install]
WantedBy=timers.target
--------------------------------------------
certbot.service:
---------------------------------------------
[Unit]
Description=Certbot
Documentation=file:///usr/share/doc/python-certbot-doc/html/index.html
Documentation=https://letsencrypt.readthedocs.io/en/latest/
[Service]
Type=oneshot
ExecStart=/usr/bin/certbot -q renew
PrivateTmp=true
QUESTION:
Can I edit these 2 files to change the invocation by setting
Description=Run certbot-auto once daily
OnCalendar=*-*-* 12:00:00
and
ExecStart=/usr/local/bin/certbot-auto -q renew
Do I have to restart something to notify systemd on the changed schedule (to once a day)?
ANSWER:
It seems to be OK just editing based on the following in the log file:
2019-12-29 00:46:30,236:DEBUG:certbot._internal.main:certbot version: 1.0.0
2019-12-29 00:46:30,237:DEBUG:certbot._internal.main:Arguments: []
2019-12-29 00:46:30,237:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#manual,PluginEntryPoint#nginx,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2019-12-29 00:46:30,256:DEBUG:certbot._internal.log:Root logging level set at 20
2019-12-29 00:46:30,257:INFO:certbot._internal.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2019-12-29 00:46:30,312:DEBUG:certbot._internal.plugins.selection:Requested authenticator <certbot._internal.cli._Default object at 0x7fb4b0ef3890> and installer <certbot._internal.cli._Default object at 0x7fb4b0ef3890>
2019-12-29 00:46:30,364:INFO:certbot._internal.renewal:Cert not yet due for renewal
2019-12-29 00:46:30,365:DEBUG:certbot._internal.plugins.selection:Requested authenticator webroot and installer None
2019-12-29 00:46:30,365:DEBUG:certbot._internal.renewal:no renewal failures
Notice that the first log line for this time shows certbot version 1.0.0 indicating that certbot-auto is in fact used.
Case closed - at least until 2020-02-24 when the cert is 30 days from expiration…