失敗した条件のテストユニットを作成して開始しました。 systemctl status
条件失敗に関する情報を表示することは可能ですが...ただ失敗した状態でテストサービスを受けることができる場合。
# systemctl status test.service -n0
● test.service
Loaded: loaded (/etc/systemd/system/test.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2018-07-10 17:01:35 BST; 16s ago
Condition: start condition failed at Tue 2018-07-10 17:01:51 BST; 1s ago
└─ ConditionKernelCommandLine=not-an-option was not met
Main PID: 4378 (code=exited, status=1/FAILURE)
障害状態は、セルがガベージコレクションされ、忘れられないようにする方法です。ただし、そうしないとデバイスが忘れられ、ステータス情報が表示されなくなります。条件付き障害も記録されません。以前のデザインの失敗状態のみが記録されます。
# systemctl reset-failed test.service
# systemctl status test.service
● test.service
Loaded: loaded (/etc/systemd/system/test.service; static; vendor preset: disabled)
Active: inactive (dead)
Jul 10 17:01:35 fedora28-vm systemd[1]: Starting test.service...
Jul 10 17:01:35 fedora28-vm systemd[1]: test.service: Main process exited, code=exited, status=1/FAILURE
Jul 10 17:01:35 fedora28-vm systemd[1]: test.service: Failed with result 'exit-code'.
Jul 10 17:01:35 fedora28-vm systemd[1]: Failed to start test.service.
それでは、この機能をどのように使用する必要がありますかsystemctl
?通常、デバイスを起動するときに最初に障害状態をテストし、起動プロセスをスキップします。したがって、失敗した状態に入る機会はありません。
システムバージョンv239-120-g0fad72faeでテストされました。
ベストアンサー1
起動プロセスの一部としてデバイスを起動できるようにすると、正常に動作します。などのアクティブデバイスに依存するデバイスは、ガベージコレクションを防ぎますmulti-user.target
。
この行をセルに追加しました。
[Install]
WantedBy=multi-user.target
その後、任意の方法で使用できます。
# systemctl enable test.service
# systemctl start test.service
# systemctl status test.service -n0
● test.service
Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Condition: start condition failed at Tue 2018-07-10 17:18:21 BST; 3s ago
└─ ConditionKernelCommandLine=not-an-option was not met