Chinaunix首页 | 论坛 | 博客
  • 博客访问: 629719
  • 博文数量: 184
  • 博客积分: 10057
  • 博客等级: 上将
  • 技术积分: 2505
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-31 16:34
文章分类

全部博文(184)

文章存档

2010年(5)

2009年(104)

2008年(75)

我的朋友

分类: LINUX

2009-04-20 21:52:43

I noticed a one liner here for working out when you started work that day. The code given was:

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 }'

阅读(437) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~