systemd が一部の Type=simple サービスに対してジョブ失敗を報告するのはなぜですか。

systemd が一部の Type=simple サービスに対してジョブ失敗を報告するのはなぜですか。

~によるとシステム文書、systemdは、子プロセスが分岐した直後に成功を報告します。これは私のクイックテスト結果と一致します。

$ cat /etc/systemd/system/test.service
[Service]
Type=simple
ExecStart=/bin/asdfg
$ systemctl daemon-reload
$ systemctl start test  # Exits immediately
$ echo $?
0
$ systemctl status test
● test.service
   Loaded: loaded (/etc/systemd/system/test.service; static; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-12-15 01:56:52 CST; 2s ago
  Process: 24483 ExecStart=/bin/asdfg (code=exited, status=203/EXEC)
 Main PID: 24483 (code=exited, status=203/EXEC)

Dec 15 01:56:52 iBug-Server systemd[1]: Started test.service.
Dec 15 01:56:52 iBug-Server systemd[24483]: test.service: Failed to execute command: No such file or directory
Dec 15 01:56:52 iBug-Server systemd[24483]: test.service: Failed at step EXEC spawning /bin/asdfg: No such file or directory
Dec 15 01:56:52 iBug-Server systemd[1]: test.service: Main process exited, code=exited, status=203/EXEC
Dec 15 01:56:52 iBug-Server systemd[1]: test.service: Failed with result 'exit-code'.
$

ただし、過去の経験によると、一部のサービスが開始または再起動されなかった場合、systemdは次のエラーを報告しnginxますssh

Job for test.service failed because the control process exited with error code.
See "systemctl status test.service" and "journalctl -xe" for details.

systemdが私のテストサービス(Freedesktop.orgのマニュアルページと一致)の失敗を報告せず、代わりに他のサービスの失敗を報告するのはなぜですか?

説明:具体的には「commands」を参照していますsystemctl start/restart。 「report failure」によりメッセージが出力され、ゼロ以外の状態で終了します。出力はsystemctl status関係ありません。

ベストアンサー1

おすすめ記事