Even when compared to the simplicity of Windows 7's shutdown function, Linux goes a step further in flexibility and ease of use. Shutting down a system at 8 AM in Linux is as easy as saying
shutdown 8:00 in a terminal. To explicitly state that the system should power down after shutting down, we would expand it to
shutdown -h 8:00. Alternatively, if we want to perform a reboot, the switch would change to
shutdown -r 8:00. The command has a number of other options including a minutes from now parameter.
Often, we will want to continue using the same terminal window rather than leaving it tied down with the
shutdown command. A neat solution for this is to
nice the directive with a trailing ampersand. In other words,
shutdown -h 8:00 & will background the task and leave us unimpeded. The
-c switch can be used to cancel any backgrounded shutdown calls.
Hope this helps!
The following is an excerpt from the shutdown command's man page:
shutdown - bring the system down
shutdown [OPTION]... TIME [MESSAGE]
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.
TIME may have different formats, the most common is simply the word 'now' which will bring the system down immediately. Other valid formats are
+m, where m is the number of minutes to wait until shutting down and hh:mm which specifies the time on the 24hr clock.
Once TIME has elapsed, shutdown sends a request to the init(8) daemon to bring the system down into the appropriate runlevel.
This is performed by emitting the runlevel(7) event, which includes the new runlevel in the RUNLEVEL environment variable as well as the previous
runlevel (obtained from the environment or from /var/run/utmp) in the PREVLEVEL variable. An additional INIT_HALT variable may be set, this will
contain the value HALT when bringing the system down for halt and POWEROFF when bringing the system down for power off.
-r Requests that the system be rebooted after it has been brought down.
-h Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system.
-H Requests that the system be halted after it has been brought down.
-P Requests that the system be powered off after it has been brought down.
-c Cancels a running shutdown. TIME is not specified with this option, the first argument is MESSAGE.
-k Only send out the warning messages and disable logins, do not actually bring the system down.
shutdown will read the current runlevel from this environment variable if set in preference to reading from /var/run/utmp
Where the current runlevel will be read from; this file will also be updated with the new runlevel.
A new runlevel record will be appended to this file for the new runlevel.
The Upstart init(8) daemon does not keep track of runlevels itself, instead they are implemented entirely by its userspace tools.
See runlevel(7) for more details.
Written by Scott James Remnant <*hidden*>
- Log in to post comments