Q. I’d like to monitor my UNIX / Linux server reboot / shutdown usage. How do I get more information about reboot and shutdown command?
A. There is a file called /var/log/wtmp. The pseudo user reboot logs in each time the system is rebooted. Thus last reboot will show a log of all reboots since the log file was created.
wtmp also contains information about reboots and shutdowns, you can list that information, by typing the following command at the shell prompt:
$ sudo last reboot
# last reboot
reboot system boot 2.6.22-14-generi Wed Oct 24 08:03 - 08:48 (00:44) reboot system boot 2.6.22-14-generi Tue Oct 23 21:21 - 00:40 (03:18) reboot system boot 2.6.22-14-generi Tue Oct 23 14:29 - 19:55 (05:26) reboot system boot 2.6.22-14-generi Mon Oct 22 18:36 - 19:55 (1+01:19) reboot system boot 2.6.22-14-generi Mon Oct 22 17:05 - 19:55 (1+02:50) reboot system boot 2.6.22-14-generi Mon Oct 22 14:50 - 17:03 (02:13) reboot system boot 2.6.22-14-generi Mon Oct 22 13:28 - 13:29 (00:01) reboot system boot 2.6.22-14-generi Mon Oct 22 13:07 - 13:27 (00:20) reboot system boot 2.6.22-14-generi Sun Oct 21 14:38 - 08:20 (17:42) reboot system boot 2.6.22-14-generi Sat Oct 20 10:53 - 12:54 (1+02:00) reboot system boot 2.6.22-14-generi Fri Oct 19 21:18 - 01:41 (04:22) reboot system boot 2.6.22-14-generi Fri Oct 19 16:07 - 01:41 (09:34) reboot system boot 2.6.22-14-generi Thu Oct 18 22:56 - 12:32 (13:35) reboot system boot 2.6.22-14-generi Thu Oct 18 14:30 - 12:32 (22:01)
You can also type the following command to get halt / shutdown time only:
$ last -x | grep down
vivek tty1 Mon Oct 22 13:25 - down (00:01) vivek tty7 :0 Mon Oct 22 13:08 - down (00:19) vivek tty1 Thu Oct 18 14:25 - down (00:04) vivek tty7 :0 Thu Oct 18 14:24 - down (00:04) vivek tty1 Thu Oct 18 14:16 - down (00:00) vivek tty1 Thu Oct 18 14:13 - down (00:02)
Q. I’ve just installed Ubuntu Linux on my computer. I’d like to know – how to shutdown Ubuntu box over ssh session?
A. If you are not using GUI, you can run halt or shutdown command to powerdown box.
shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and, within the last five minutes of TIME, new logins are prevented. The shutdown utility provides an automated shutdown procedure for supersers to nicely notify users when the system is shutting down, saving them from system administrators, hackers, and gurus, who would otherwise not bother with such niceties.
How do I use shutdown command?
The shutdown command can be used to turn off or reboot a computer. Type the command as follows to shutdown server / computer immediately:
$ sudo shutdown -h now
$ sudo shutdown -h 0
How do I shutdown compute at specific time?
To shutdown computer at 6:45pm, enter:
$ sudo shutdown -h 18:45 "Server is going down for maintenance"
At 6:30pm message will go out to all user and 6:45 system will shutdown.
Please note that you can also use halt or poweroff or reboot command for stopping and restarting the system:
$ sudo halt
$ sudo poweroff
How do I reboot computer?
Simply use reboot command:
$ sudo reboot
$ sudo shutdown -r 0