我想創建一個計時器,每 2 個月(每月的第一天)啟動一個命令,我已經使用 cron 做到了這一點,但我想對 systemd 做同樣的事情並擺脫 cron。
我有一個問題,因為當我啟動計時器時,systemd 拒絕啟動它並出現以下錯誤:
systemd[1]: Starting Start my timer.
systemd[1]: myservice.timer failed to enter waiting state: Invalid argument
systemd[1]: Failed to start Start my timer
systemd[1]: Unit myservice.timer entered failed state.
我使用了以下兩個單位:
myservice.timer
[Unit]
Description=Start my timer
[Timer]
OnCalendar=*-01/2-01 00:00:01
Persistent=true
WakeSystem=true
[Install]
WantedBy=timers.target
myservice.service
[Unit]
Description=Start my command
[Service]
Type=oneshot
ExecStart=/usr/local/mycommand.sh
[Install]
WantedBy=multi-user.target
我想它不起作用,因為它缺少參數或 OnCalendar 參數不好。我使用的是 Debian Jessie。
謝謝。