Systemd Timer alle 8 Stunden
Sep 08 2020
Ich bin ziemlich neu in der Verwendung von Systemd-Timern und habe einige Probleme.
Ich versuche, ein Skript zu planen, das täglich alle 8 Stunden um 6 Uhr, 14 Uhr und 22 Uhr ausgeführt wird. Die Zeit beginnt korrekt und zeigt die nächste geplante Zeit an (was sie tut), aber dann scheint sie nie die dritte (oder eine andere) Zeit zu laufen. Was mache ich falsch?
Ich habe dies in meinem Timer:
[Unit]
Description=Run every 8 hours
Requires=script.service
[Timer]
OnCalendar=*-*-* 03,11,19:00:00
Persistent=true
[Install]
WantedBy=timers.target
Ich habe auch Folgendes versucht:
[Unit]
Description=Run every 8 hours
Requires=script.service
[Timer]
OnCalendar=*-*-* 03,11,19:00:00
OnUnitActiveSec=1d
Persistent=true
[Install]
WantedBy=timers.target
Und das:
[Unit]
Description=Run every 8 hours
Requires=script.service
[Timer]
OnCalendar=*-*-* 03:00:00
OnCalendar=*-*-* 11:00:00
OnCalendar=*-*-* 19:00:00
Persistent=true
[Install]
WantedBy=timers.target
Bedienung:
[Unit]
Description=Renews Kerberos ticket every 8 hours
After=network-online.target firewalld.service
Wants=network-online.target script.timer
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/bin/kdestroy
ExecStart=/usr/bin/kinit -R -V [email protected] -k -t /etc/krb5.keytab
IOSchedulingClass=best-effort
[Install]
WantedBy=default.target
'''
Antworten
1 ajgringo619 Sep 08 2020 at 06:49
OK, ich glaube, das Problem liegt in der Datei script.service . Laut systemd.timerManpage:
DESCRIPTION
Note that in case the unit to activate is already active at the time the timer elapses it is not restarted, but simply left running. There is no concept of spawning new service instances in this case. Due to this, services
with RemainAfterExit= set (which stay around continuously even after the service's main process exited) are usually not suitable for activation via repetitive timers, as they will only be activated once, and then stay
around forever.
Entfernen Sie die RemainAfterExit=Leitung und Sie sollten bereit sein zu gehen.