From 487e82cf2be55c9c4c1d2fbd313ccde7f3fbc8d9 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Sat, 24 Aug 2024 14:49:08 -0700 Subject: [PATCH] Improve journal time extraction It will now work even if the log file is completely empty, whereas it previously required at least one log message to exist. --- automtime | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automtime b/automtime index d1bab70..ef85bed 100755 --- a/automtime +++ b/automtime @@ -446,9 +446,9 @@ mtime_jpeg () { # File type: journal (journald log file) # requires: systemd mtime_journal () { - RAWTIME=$(journalctl -e -o export --output-fields=__REALTIME_TIMESTAMP --file "$f" | grep ^__REALTIME_TIMESTAMP= | tail -1 | sed -E 's/^.*=([0-9]{10})(.*)$/\1.\2/') - # $RAWTIME is like 1234567890.123456 - TIME=$(normalize_time_tz "@$RAWTIME") + RAWTIME=$(TZ=UTC journalctl --header --file "$f" | sed -E -n 's/Tail realtime timestamp: (.*) \(.*\)$/\1/p') + # $RAWTIME is like Sat 2024-08-24 14:33:29 UTC + TIME=$(normalize_time_tz "$RAWTIME") } # File type: jxl (JPEG XL)