diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2022-02-22 11:06:00 +0000 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2022-02-23 20:09:50 +0000 |
commit | 0802f62efc1d1c67d5be67223b529c93536cf2ed (patch) | |
tree | ed8a8483d89050af0763ca242d86e9cca6d55833 /src/systemctl | |
parent | 80ff9567048d0a4aa57e13e9651713798c7fe7bb (diff) | |
download | systemd-0802f62efc1d1c67d5be67223b529c93536cf2ed.tar.gz |
systemctl: Show how long a service ran for after it exited in status output
Diffstat (limited to 'src/systemctl')
-rw-r--r-- | src/systemctl/systemctl-show.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 76418196c6..c1298ce758 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"); |