1

Looking through the Archwiki on journalctl and systemd I do not see a means of configuring the system log to display in a 12 hour format with am and pm. The 24 hour format works fine; however, I need to convert from 24 hour to 12 hour to check the log against the current system time. Is there a systemd config file or journalctl argument (I know about -o) that causes journalctl to display 12 hour format with am and pm?

1 Answer 1

3

There's no such option. The time formatting options are limited (either locale-dependent, but still 24-hour, or Unix timestamps, or ISO 8601 timestamps).

I'd just check the current date in 24-hour format (and put it in a prompt or a widget somewhere):

% date +%T   
18:40:59

But you can also parse the journalctl output and convert the timestamps:

# journalctl --output=short-unix -b | awk '/^[0-9]/ {sub(/^[0-9]+\.[0-9]+/, strftime("%F %I:%M:%S %p"))} 1' | head
-- Logs begin at Sat 2018-08-25 19:16:53 JST, end at Sun 2019-06-23 18:37:04 JST. --
2019-06-23 06:37:50 pm cthulhu kernel: Linux version 5.1.11-arch1-1-ARCH (builduser@heftig-31251) (gcc version 9.1.0 (GCC)) #1 SMP PREEMPT Mon Jun 17 18:56:30 UTC 2019
2019-06-23 06:37:50 pm cthulhu kernel: KERNEL supported cpus:
2019-06-23 06:37:50 pm cthulhu kernel:   Intel GenuineIntel
2019-06-23 06:37:50 pm cthulhu kernel:   AMD AuthenticAMD
2019-06-23 06:37:50 pm cthulhu kernel:   Hygon HygonGenuine
2019-06-23 06:37:50 pm cthulhu kernel:   Centaur CentaurHauls
2019-06-23 06:37:50 pm cthulhu kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'

We tell journalctl to print Unix timestamps, and use awk to replace that with a timestamp using 12-hour format.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .