削除する前に systemd サービスを実行してください。

削除する前に systemd サービスを実行してください。

終了時にsystemdサービスを実行しようとしています。動作しますが(呼び出し済み)、ファイルシステムがアンマウントされた後に実行されるため、必要ではありません。だから運がBefore=umount.targetあるかどうかを試しましたWantedBy=umount.target(サービスを実行する前にファイルシステムをマウント解除します)。 「ファイルシステム」とは、ルートを除くすべてのファイルシステムを意味します。

注意すべき他の目標はありますか?

ベストアンサー1

DefaultDependencies=noサービスファイルの単位セクションに追加してみてください。システムサービスマニュアルページには次のように記載されています。

DefaultDependency=no が設定されていない場合、次の依存関係が追加されます。

  •   Service units will have dependencies of type Requires= and After= on sysinit.target, a dependency of type After= on basic.target as well
      as dependencies of type Conflicts= and Before= on shutdown.target. These ensure that normal service units pull in basic system
      initialization, and are terminated cleanly prior to system shutdown. Only services involved with early boot or late system shutdown
      should disable this option.

...

おすすめ記事