systemdタイマーは8時間ごとに実行されます。

systemdタイマーは8時間ごとに実行されます。

私はsystemdタイマーを初めて使用する際にいくつかの問題があります。

毎日、8時間ごと、午前6時、午後2時、午後10時にスクリプトが実行されるようにスケジュールしようとしています。時間が正しく開始され、次のスケジュールされた実行時間が表示されますが(はい)、3番目(または他の)時間には実行されないようです。私は何が間違っていましたか?

私のタイマーには次のものがあります。

[Unit]
Description=Run every 8 hours
Requires=script.service

[Timer]
OnCalendar=*-*-* 03,11,19:00:00
Persistent=true

[Install]
WantedBy=timers.target

私もこれを試しました:

[Unit]
Description=Run every 8 hours
Requires=script.service

[Timer]
OnCalendar=*-*-* 03,11,19:00:00
OnUnitActiveSec=1d
Persistent=true

[Install]
WantedBy=timers.target

これ:

[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

提供する:

[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
'''

ベストアンサー1

わかりました、私の考えでは問題はスクリプトサービス文書。systemd.timerマニュアルページによると:

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.

行を削除するRemainAfterExit=と行くことができます。

おすすめ記事