3

journalctl has the -o short-unix flag that I can use to change the output date format on stuff like -t systemd-sleep.

But the only way I've found to list boots is --list-boots, and this doesn't seem to obey the -o flag.

Is there a way to make journalctl list boots with unix timestamps? Since systemd is here to stay I fear other methods might break in the future, but I'm open to those suggestions too.

  • 3
    You can however convert those fields into unix timestamps. I.e: journalctl --list-boots | awk '{ d2ts="date -d \""$3" "$4" " $5"\" +%s"; d2ts | getline $(NF+1); close(d2ts)} 1' – Valentin Bajrami Jun 28 '19 at 10:29
  • Thanks. Still a bit confused on how this works, but it should do the job as long as the format doesn't change much. – madprops Jun 28 '19 at 10:41
  • @ madprops, posted the above as an answer so it is better searchable and probably more useful to others than having it just as a comment. – Valentin Bajrami Jul 5 '19 at 10:12
0

You can however convert those fields into unix timestamps. I.e:

journalctl --list-boots | awk '{ d2ts="date -d \""$3" "$4" " $5"\" +%s"; d2ts | getline $(NF+1); close(d2ts)} 1'
| improve this answer | |
0

You can use an alternative tool called tuptime to get exact the same information. As example:

tuptime -bits
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.