OnCalendarシステムタイマーデバイスは起動時に実行され続けます。これを止める方法は?

OnCalendarシステムタイマーデバイスは起動時に実行され続けます。これを止める方法は?

次のデバイスを有効にして起動しました。

[Unit]
Description=Schedule a nightly execution at 03.15 for Backup ROOT
# Allow manual start
RefuseManualStart=no
# Allow manual stop
RefuseManualStop=no

[Timer]
#Execute job if it missed a run due to machine being off
Persistent=false
# Run every night 03.15
OnCalendar=*-*-* 03:15:00
#File describing job to execute
[email protected]

[Install]
WantedBy=timers.target

毎晩午前3時15分に正しく実行されますが、混乱を招く開始時にも実行されます!なぜこれが起こり、それを止めるのですか?

ベストアンサー1

これは素晴らしい答えを得ましたこの回答到着 起動時にシステムタイマーが実行されないようにする

要約すると

問題は、.serviceファイルの[Install]セクションにWantedBy = basic.targetなどのエントリが常に含まれることです(標準のシステムサービスレプリケーションスパゲッティの一部であるため)。これは、実際にbasic.targetが起動したときに(システム起動とも呼ばれる)、デバイスが起動することを示しています。

https://www.freedesktop.org/software/systemd/man/systemd.unit.html#WantedBy= https://www.freedesktop.org/software/systemd/man/systemd.special.html#basic.target

長すぎると、.serviceファイルの[Install]セクションが.timerファイルによってトリガーされることを望ましくありません。

追加ステップとしてサービスを無効にする必要がありますsystemctlを無効にする[サービス名]

その後、再度有効にしたい場合は有効にできず、次のようなエラーが表示されます。

と書かれた部分に注目してください

...必要に応じてアクティブ化から始まります(ソケット、パス、タイマー...

The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

    Possible reasons for having this kind of units are:

• A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.

おすすめ記事