Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 4783  / 3 Years ago, tue, november 23, 2021, 11:26:32

If I execute systemctl is-active <service-name>, what will be the value of result code when service was active but it failed? 0 (success) or another?


More From » systemd

 Answers
7

Alright, so based on a recent failure on my auto-restart script it seems systemctl --quiet is-active <service-name> returned 0, which makes sense in a way with the obtained active(failed) detailed output I remember from an older failure case.


Solution is probably to check for is-failed instead, given that I don't have the need to auto-restart my service in case it was explicitly stopped (to what the original command shall return non-0 and its detailed output contain inactive, naturally), and given I want it to be restarted when failed.


[#669] Tuesday, November 23, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
serveeel

Total Points: 347
Total Questions: 106
Total Answers: 117

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
serveeel questions
Thu, Jan 13, 22, 12:38, 2 Years ago
Sat, Oct 9, 21, 04:32, 3 Years ago
;