The BSD shutdown Command

Ensure that filesystem integrity is maintained by completing all pending disk updates. • Fortunately, UNIX designers have provided the shutdown command and its derivatives to fulfill all the required steps smoothly. The only responsibility of a system administrator is to implement the command when the system is going to be shut down. The reboot command is also supported for a majority of UNIX flavors on both platforms. It usually represents a renamed version of the shutdown command, although it can also have its own options. For example, on the HP−UX platform the reboot command behaves differently from the shutdown −r command the −r option indicates rebooting. While the shutdown command terminates all processes gracefully it sends the TERM signal to processes, the reboot command kills all processes unconditionally it sends the KILL signal to processes. It is highly recommended that you check the manual pages for the availability, options, and behavior of the reboot command before using it on any UNIX platform.

4.5.1 The BSD shutdown Command

The BSD shutdown command has the following syntax: shutdown time message where time Can have one of the three forms: now For immediate shutdown +m For shutdown after m minutes hh:mm For shutdown at this time on the 24−hour clock message An announcement that is sent to all users; the message is repeated with increased frequency as the shutdown time approaches Some BSD flavors support a nonstandard shutdown configuration file etcrc.shutdown. In this case, the system administrator may place any desired command in the file, enabling its execution at shutdown. The shutdown command also creates the file etcnologin, which automatically denies any future user attempts to log in to the system, and the contents of the file are displayed to the user. The file is deleted by the etcrc script during system booting. Several options are supported, among them: shutdown −r Allows the system to be shut down and rebooted automatically as soon as the system enters single−user modeor after a default time interval if not specified with command itself shutdown −f Allows the system to be shut down and quickly rebooted automatically as soon as the system enters single−user mode without filesystem checking shutdown −h Allows the system to be shut down and halted at the point where the power may be safely turned off shutdown −k Performs a fake shutdown with the message sent to all users, but no shutdown actually occurs 107 The System V shutdown command has the following syntax: shutdown −gn −ilevel [−y] where n Number of seconds to wait for the shutdown to begin the default value is 60 s level Run−level in which system should be placed: 0 — to turn off power • 1 — administrative state • S — single−user mode default • 5 — firmware state • 6 — reboot to initdefault state in etcinittab • y Optional preanswered query for shutdown confirmation yes; otherwise the command will prompt for confirmation just before the system goes down Older System V flavors required input to the shutdown command from the system console. However, this could be easily bypassed by executing the command from any terminal and redirecting the standard input to the console, with the −y option included: shutdown −g120 −i6 −y devconsole devconsole 21 To shutdown a system immediately and reboot automatically: shutdown −g0 −i6 −y To shutdown and halt a system after 60 s − default time: shutdown −i5 −y

4.5.3 An Example