I can list past boots of my machine with journalctl --list-boots
. The output looks something like this:
-4 21b1318cbaf04732b95ed0a5e40f6698 Tue 2019-06-25 17:26:53 CEST—Fri 2019-07-05 17:11:31 CEST
-3 02d30049fdef4a809122f499ef95d122 Fri 2019-07-05 17:12:33 CEST—Wed 2019-08-14 10:23:47 CEST
-2 aedc9088bd0a4a9588c387e593c9cc25 Wed 2019-08-14 10:24:41 CEST—Fri 2019-09-20 16:28:12 CEST
-1 e40c23b16b86400292b7da77f03f677f Fri 2019-09-20 16:29:03 CEST—Mon 2019-10-07 16:31:20 CEST
0 973dc1142add4a249e784c1a68fac31a Mon 2019-10-07 16:32:11 CEST—Tue 2019-10-15 12:12:22 CEST
So I can use this to find out when the computer was booted and when it was shut down.
I want to have the same information for a single systemd unit (in my case a .service). But I did not find a way to get this information. The obvious journalctl -u foo.service
returns lines like these:
Oct 10 00:00:01 localhost systemd[1]: Started foo service.
Oct 10 00:00:02 localhost foo[19382]: some foo output
Oct 10 00:00:02 localhost foo[19382]: some foo output
Oct 10 00:00:02 localhost foo[19382]: some foo output
Oct 10 00:00:02 localhost foo[19382]: some foo output
Oct 10 00:00:02 localhost foo[19382]: some foo output
Oct 10 00:00:02 localhost foo[19382]: some foo output
Oct 10 00:11:22 localhost foo[19382]: some foo output
Oct 10 12:00:01 localhost systemd[1]: Started foo service.
...
From this I can find out that the service was started on 00:00:01 and again on 12:00:01 but I do not know how long it ran for exactly (only that it ran at least until 00:11:22).
Background: I want to find out if the service (a backup script in my case) did take more or less time in the past.