Skip to content
Snippets Groups Projects
Commit 3e88dade authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

fix date time handling

parent 51fe96cd
No related branches found
No related tags found
1 merge request!187fix date time handling
......@@ -85,15 +85,21 @@ lastLine=$( cat "$tmpfile" 2>/dev/null )
if [ -z "$lastLine" ]; then
ph.setStatus unknown
ph.status "Initializing ... storing last line of jorunallog ..."
journalctl -n 1 > "$tmpfile"
journalctl -n 1 | tail -1 > "$tmpfile"
else
ts=$( cut -f 1-3 -d " " <<< "$lastLine" )
# mydate is "Okt 12 16:23:36"
# mydate=$( cut -f 1-3 -d " " <<< "$lastLine" )
# what works:
# date -d "12 sec ago" +"%Y-%m-%d %H:%I:%S"
# date -d "Oct 12 14:24:04" +"%Y-%m-%d %H:%M:%S"
typeset -i iAge; iAge=$( ph.getFileAge "$tmpfile" )
# ts=$( date -d "${mydate}" +"%Y-%m-%d %H:%M:%S" )
ts=$( date -d "${iAge} sec ago" +"%Y-%m-%d %H:%M:%S" )
data=$( sudo journalctl --since "$ts" )
# for next run: insert last handled line
tail -1 <<< "$data" > "$tmpfile"
# detect last seen position and count lines from there
typeset -i iTotal; iTotal=$( wc -l <<< "$data" )
typeset -i iFrom; iFrom=$( grep -Fn "$lastLine" <<< "$data" | head -1 | cut -f 1 -d ':' )
......@@ -121,6 +127,9 @@ else
echo "Limits: $sLimits"
echo "Raw data: Found $iLines new line(s) in the last $iAge sec"
# for next run: insert last handled line
test $iLines -gt 0 && tail -1 <<< "$data" > "$tmpfile"
fi
# cat "$tmpfile"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment