From: Daan De Meyer Date: Tue, 22 Feb 2022 11:06:00 +0000 (+0000) Subject: systemctl: Show how long a service ran for after it exited in status output X-Git-Tag: v251-rc1~229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0802f62efc1d1c67d5be67223b529c93536cf2ed;p=thirdparty%2Fsystemd.git systemctl: Show how long a service ran for after it exited in status output --- diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 76418196c6a..c1298ce7583 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -433,6 +433,18 @@ static void print_status_info( FORMAT_TIMESTAMP_STYLE(until_timestamp, arg_timestamp_style), FORMAT_TIMESTAMP_RELATIVE(until_timestamp)); } + + if (!endswith(i->id, ".target") && + STRPTR_IN_SET(i->active_state, "inactive", "failed") && + timestamp_is_set(i->active_enter_timestamp) && + timestamp_is_set(i->active_exit_timestamp) && + i->active_exit_timestamp >= i->active_enter_timestamp) { + + usec_t duration; + + duration = i->active_exit_timestamp - i->active_enter_timestamp; + printf(" Duration: %s\n", FORMAT_TIMESPAN(duration, MSEC_PER_SEC)); + } } else printf("\n");