Date of latest d-u

Begonnen von mylo, 2015/10/05, 23:23:33

Vorheriges Thema - Nächstes Thema

mylo

Hi all,

how can I find out when I made the last d-u on my installation?

piper

/var/log/apt/history.log
I have a Lucky Rabbit:    "Svoot" ..... (It's Swedish)

I am MAGA

musca

Hello,
you can have a script reading the log for you.


$ awk 'BEGIN {latest="not yet this month"} /dist-upgrade/ { latest=last"  "$0;} { last=$0; } END { print latest }' /var/log/apt/history.log
Start-Date: 2015-10-05  23:46:46  Commandline: apt dist-upgrade



$ perl -wlne 'BEGIN {$latest="not yet this month"} /dist-upgrade/ and $latest="$last  $_"; $last=$_; END { print $latest }' /var/log/apt/history.log
Start-Date: 2015-10-05  23:46:46  Commandline: apt dist-upgrade


That perl example seems to imitate the awk style. I'm sure there are other solutions, that are more "perlish".

greetings
musca
,,Es irrt der Mensch, solang er strebt."  (Goethe, Faust)

der_bud

Uh, those look very awkish and perlish for my simple mind ;) . I generate a bit more output with grep 'dist-upgrade' /var/log/apt/history.log -a1 If too much, could be followed by |tail -2 ).
Du lachst? Wieso lachst du? Das ist doch oft so, Leute lachen erst und dann sind sie tot.

musca

#4
agreed, you don't need awk or perl when you have bash.


$ (latest="not yet this month"; while read line; do [[ $line =~ dist-upgrade ]] && latest="$last $line"; last="$line "; done ; printf "$latest\n") </var/log/apt/history.log
Start-Date: 2015-10-05  23:46:46  Commandline: apt dist-upgrade


and you can do it with lua:
$ lua -e 'latest="not yet this month"; for line in io.lines() do if string.find(line,"dist%-upgrade") then latest=last.."  "..line end last=line end io.write(latest.."\n")' </var/log/apt/history.log
Start-Date: 2015-10-05  23:46:46  Commandline: apt dist-upgrade


greetings
musca
,,Es irrt der Mensch, solang er strebt."  (Goethe, Faust)

mylo

Thanks for your hinter, I will try all of them!