0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Systemctl Timerが動かないなと思ったら

Posted at

Timerが動かない、、?

タイトル通りなんですけどね。
こんな感じになっちゃいます。

$ sudo systemctl list-timers
NEXT                        LEFT          LAST                        PASSED             UNIT                           ACTIVATES                       
...
n/a                         n/a           n/a                         n/a                test01.timer                   test01.service

何が悪かったの?

もともとの設定はこんなです。
1分おきに淡々と処理を繰り返すようにしたかったのですが、、

$ sudo systemctl cat test01.timer
# /etc/systemd/system/test01.timer
[Unit]
Description=My Script Timer

[Timer]
OnUnitActiveSec=1m

[Install]
WantedBy=timers.target

結論としては、[Timer]のところに1行足りませんでした。
OnStartupSec=10m とかを足せばOK。

ただし、1回OSを再起動もしないと駄目っぽいですが。

これどういうことだったかというと、元の「OnUnitActiveSec」は前回実行からX後に次の回を実施するという設定。
で、それだけだと、「最初の1回」を実行する指定がされてないのですね。。
最初の1回が無いので、次以降の回も無い、ということのようです。
OnStartupSecなり、OnBootSecなりを指定して、最初の1回の実施タイミングを合わせて指定してやればOK。

蓋を開ければそりゃそうだなんですけど、ちと調査に手こずりました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?