Skip to content

Commit

Permalink
systemctl: Show how long a service ran for after it exited in status …
Browse files Browse the repository at this point in the history
…output
  • Loading branch information
DaanDeMeyer authored and bluca committed Feb 23, 2022
1 parent 80ff956 commit 0802f62
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/systemctl/systemctl-show.c
Expand Up @@ -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");

Expand Down

0 comments on commit 0802f62

Please sign in to comment.