Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1364192
  • 博文数量: 704
  • 博客积分: 10140
  • 博客等级: 上将
  • 技术积分: 6230
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-15 20:41
文章分类

全部博文(704)

文章存档

2013年(1)

2012年(16)

2011年(536)

2010年(151)

分类: LINUX

2010-12-29 12:08:29

So how do you find Linux / UNIX system last reboot or shutdown date and time? The last utility will either list the sessions of specified users, ttys, and hosts, in reverse time order, or list the users logged in at a specified date and time. Each line of output contains the user name, the tty from which the session was conducted, any hostname, the start and stop times for the session, and the duration of the session.

who command

You need to use who command, to print who is logged on. It also displays the time of last system boot. Use last command to display system reboot and shutdown date and time.
$ who –b
Output:

system boot  Apr 30 15:08

Use last command to display listing of last logged in users and system last reboot time and date:
$ last reboot | less
Or better try:
$ last reboot | head -1
Output:

reboot   system boot  2.6.15.4         Sun Apr 30 15:08 - 16:22  (01:13)

last command searches back through the file /var/log/wtmp and displays a list of all users logged in (and out) since that file was created. The pseudo user reboot logs in each time the system is rebooted. Thus last reboot command will show a log of all reboots since the log file was created.

To display last shutdown date and time use following command:
$ last -x|grep shutdown | head -1
Output:

shutdown system down  2.6.15.4         Sun Apr 30 13:31 - 15:08  (01:37)

Where,

  • -x: Display the system shutdown entries and run level changes.

For more information read last command man page.

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