Results 1 to 4 of 4
Hi,
I need to find the last system shutdown time. I got a command last that is used for this.But the command is not give the year. Below i posted ...
- 01-12-2011 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 3
Find last system shut down time
Hi,
I need to find the last system shutdown time. I got a command last that is used for this.But the command is not give the year. Below i posted the sample output
Sample output:
last -x | grep shutdown
shutdown system down 2.6.31.5-server- Tue Jan 11 11:45 - 11:46 (00:00)
shutdown system down 2.6.31.5-server- Sat Dec 11 11:25 - 11:45 (31+00:20)
shutdown system down 2.6.31.5-server- Mon Jan 10 21:04 - 10:31 (13:27)
shutdown system down 2.6.31.5-server- Fri Jan 7 17:38 - 11:05 (2+17:26)
shutdown system down 2.6.31.5-server- Thu Jan 6 20:39 - 10:00 (13:21)
shutdown system down 2.6.31.5-server- Wed Jan 5 19:48 - 10:46 (14:5
shutdown system down 2.6.31.5-server- Tue Jan 4 20:13 - 09:51 (13:3
year field is important for me. how can i get that or is any command is used to get the system last down time in Linux?
Guide me.
- 01-12-2011 #2Just Joined!
- Join Date
- Jan 2011
- Posts
- 4
Well, as you found out the last command doesn't include the year which is unfortunate. This means you will have to find a way to parse the /var/log/wtmp file yourself. It's not a text file so it's going to require some special handling.
A little googling turned up the following three page article that should give you an idea on how to get the data your looking for out of the /var/log/wtmp file. I read through it and learned a few things myself. I'm not well versed in perl but it was suggested to read the free online chapter from "Perl for System Administration" for even better ways to handle wtmp. Good luck on that. Here is the article:
It would appear that I am restricted from posting links to websites hence the wtf misspelling. Just trying to help.Code:wtf.itworld.com/nls_unixlastlogin050331?page=0%2C0
- 01-12-2011 #3
Use -F to get the full date and time. It's presented in a slightly different format than just using -x, but it does give the year. "man last" gives more detail.
- 03-22-2012 #4Just Joined!
- Join Date
- Mar 2012
- Posts
- 1


Reply With Quote

