Systemd 服務/計時器 - 帶計時器的一次性服務執行多次,但因「start-limit-hit」而失敗

Systemd 服務/計時器 - 帶計時器的一次性服務執行多次,但因「start-limit-hit」而失敗

我想透過 systemd.timer 單元每 5 分鐘啟動一個命令(一致)作為 systemd.service 。僅“.service”文件就可以正常運作。但是,當它由計時器單元啟動時,它會運行多次並因以下錯誤而停止:Start request repeated too quickly.Failed with result 'start-limit-hit'。但為什麼?

我像這樣啟動計時器服務:systemctl --user start service.timer

這些文件位於:$HOME/.config/systemd/user/.

同步服務

[Unit]
Description=Sync Service

[Service]
Type=oneshot
ExecStart=/bin/zsh -l -c "unison -batch %u"
ExecStartPost=/bin/zsh -l -c 'dunstify "sync ~"'

[Install]
WantedBy=graphical.target

同步定時器

[Unit]
Description=Timer for Sync Service

[Timer]
OnCalendar=*-*-* *:0/5:*
AccuracySec=5s

[Install]
WantedBy=timers.target

unison 指令透過 ssh 使用受密碼保護的金鑰檔案透過網路同步到伺服器。實例ssh-agent正在由使用者運行。這就是為什麼我必須使用登入 shell: zsh -l -c "..."

答案1

鄭重聲明:OnCalendar=*-*-* *:0/5:*這完全是錯的。OnCalendar=*-*-* *:0/5:00確實停止了多次執行。

相關內容