Siduction Forum

Siduction Forum => Installation - Support => Topic started by: mylo on 2015/10/05, 23:23:33

Title: Date of latest d-u
Post by: mylo on 2015/10/05, 23:23:33
Hi all,

how can I find out when I made the last d-u on my installation?
Title: Re: Date of latest d-u
Post by: piper on 2015/10/06, 01:15:10
/var/log/apt/history.log
Title: Re: Date of latest d-u
Post by: musca on 2015/10/06, 12:18:07
Hello,
you can have a script reading the log for you.

Code: [Select]
$ 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

Code: [Select]
$ 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
Title: Re: Date of latest d-u
Post by: der_bud on 2015/10/06, 13:58:35
Uh, those look very awkish and perlish for my simple mind ;) . I generate a bit more output with
Code: [Select]
grep 'dist-upgrade' /var/log/apt/history.log -a1 If too much, could be followed by |tail -2 ).
Title: Re: Date of latest d-u
Post by: musca on 2015/10/07, 01:59:30
agreed, you don't need awk or perl when you have bash.

Code: [Select]
$ (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:
Code: [Select]
$ 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
Title: Re: Date of latest d-u
Post by: mylo on 2015/10/07, 19:28:13
Thanks for your hinter, I will try all of them!