1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

systemctl: Show how long a service ran for after it exited in status output

This commit is contained in:
Daan De Meyer 2022-02-22 11:06:00 +00:00 committed by Luca Boccassi
parent 80ff956704
commit 0802f62efc

View File

@ -433,6 +433,18 @@ static void print_status_info(
FORMAT_TIMESTAMP_STYLE(until_timestamp, arg_timestamp_style), FORMAT_TIMESTAMP_STYLE(until_timestamp, arg_timestamp_style),
FORMAT_TIMESTAMP_RELATIVE(until_timestamp)); 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 } else
printf("\n"); printf("\n");