全部博文(184)
分类: LINUX
2009-04-20 21:52:43
date "+%b %d" | xargs -i grep -m1 -i {} /var/log/syslog.0 |awk '{ print "Today I got to work at " $3 }' |
This basically just gets the time the machine was started that day.
There are a few problems here, firstly this can be done a lot easier with the 'uptime' command. More importantly though the machine I work on doesn't get rebooted each day so instead of the startup time I'd need the time I first logged in that day. This can be achieved with the following:
last $USER | sed -n '/'"$(date +"%b %d")"'/!q; p' | tail -1 | awk '{ print "Today I got to work at " $7 }' |