Return time of last world update
Came up with a short script that returns the last time @world is mentioned in /var/log/emerge.log.
date -d "1970-01-01 `grep @world /var/log/emerge.log | tail -n 1 | sed -e 's/:.*//'` sec" +"%Y-%m-%d %T %z"
Obviously you may want to modify this slightly (for example, to ignore –pretend), but I hope this will give anyone looking to script this sort of information a good starting point.
For people who use the –ask option, you’ll want to use the following, which filters out occasions where “emerge –ask @world” was run, but the user then cancelled the actual merge (answered with “no”). As you can see I also split out the command which greps the timestamp to use, for easier reading:
TIMESTAMP=`grep @world /var/log/emerge.log -A1 | grep '>>>' | tail -n1 | sed -e 's/:.*//'`
date -d "1970-01-01 ${TIMESTAMP} sec" +"%Y-%m-%d %T %z"
Also note that this version relies on users using the set notation (@world instead of just world) – but once 2.2 is out everyone will be doing that anyway (and I think set notation does work for current stable portage for the built-in sets).