Hennings blog
I’m usually quite tired when I get up in the morning. Beeing a consultant with flexible hours, it is often easy to forget exactly when I got to the office in the morning. So I figured i had to write a script to check when I started my computer. What it does is checking the syslog for the first occurence of todays date. I’m running Ubuntu linux and the syslog file is rotated a while after my computer has started. This is why I’m checking syslog.0.
The magic one liner:
date "+%b %d" | xargs -i grep -m1 -i {} /var/log/syslog.0 |awk '{ print "Today I got to work at " $3 }'
(Syntax plugin didn’t handle long lines properly. Remove the and put the entire thing on one line.)
Here you will find some of my thoughts and experiments from my daily life of programming and general geeking ;)
9 Responses to Linux one liner: When did I come to work today?
Vincent
February 27th, 2009 at 14:56
The magic one word : ‘uptime’ ;-)
Jordan
February 27th, 2009 at 15:05
Wouldn’t “uptime” be much simpler? Gives you the current time and the time your machine was on, so you can see when you turned your machine on, and how long you’ve been working.
xrado
February 27th, 2009 at 15:40
hehe nice :)
OHaleck
February 27th, 2009 at 17:16
Now that’s the beauty of Linux… Below is the Windows version I use every day:
Click – move mouse – wait – click – double click – double click – double click – double click – scroll – too far – scroll back – found.
I use eye-grep (scroll the window and try to find the info you are looking for) to find the appropriate entry in the Event Viewer.
John Parker
February 27th, 2009 at 21:23
Why not use the ‘uptime’ command?
Henning
February 28th, 2009 at 00:23
Ok, didn’t think of uptime. Why do it the easy way when you can do it the hard way? ;)
Anyway it beats Windows :)
BJ
March 2nd, 2009 at 04:13
Hey.. I found it pretty exciting… + 10 in my book.. :)
Avayan
March 19th, 2009 at 14:16
Saw this linked from http://www.shell-fu.org/lister.php?id=573
This is a really good tip though there is an alternative on the shell-fu page linked above for they who don’t restart their computer.
Thanks for the tip!
Steve
June 13th, 2011 at 16:13
Its more better tuptime, report the time between days.
http://sourceforge.net/projects/tuptime