条件付きでシステムの再起動タイムアウトを延長

条件付きでシステムの再起動タイムアウトを延長

重要な要約:特定の機密プロセスがタスクを完了するまで、要求された再起動を延期するメカニズムを構築しようとしています。


systemdにはreboot.targetデフォルト値JobTimeoutSec=30minとがありますJobTimeoutAction=force-reboot

ExecStop中断することなく完了できる必要がある作業があります。したがって、サービスにTimeoutStopSec=infinity;このストップジョブがオンのディスパッチをブロックしている場合、ストップジョブがまだreboot.target実行中であっても最終的に強制的に再開されますJobTimeoutreboot.target


reboot.targetこの問題を解決しようとする現在の試みは、デフォルト値JobTimeoutAction=force-rebootに置き換えて、次のイベントをJobTimeoutAction=exit追加するオーバーレイを構築することです。OnFailure

# /etc/systemd/system/reboot.target.d/defer-if-critical-job-running.conf
[Unit]
JobTimeoutAction=exit
FailureActionExitStatus=1
OnFailure=reboot-now-unless-critical-job-is-running.service
# /etc/systemd/system/reboot-now-unless-critical-job-is-running.service
[Unit]
Description=Reboot unless a critical job is running
DefaultDependencies=no

[Service]
ExecStart=/bin/sh -c 'if systemctl is-active some-critical-job.service; then systemctl reboot; else systemctl reboot --force; fi'

しかし、これは実際には機能しません。JobTimeoutオンになるとすぐに強制的に再起動します。reboot.target

再起動を無期限に延期するにはどうすればよいですか?ただ特定の重要なタスクが実行されているとき?

ベストアンサー1

おすすめ記事