xref: /freebsd/sbin/shutdown/shutdown.8 (revision f374ba41)
1.\" Copyright (c) 1988, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)shutdown.8	8.2 (Berkeley) 4/27/95
29.\" $FreeBSD$
30.\"
31.Dd November 7, 2022
32.Dt SHUTDOWN 8
33.Os
34.Sh NAME
35.Nm shutdown ,
36.Nm poweroff
37.Nd "close down the system at a given time"
38.Sh SYNOPSIS
39.Nm
40.Op Fl
41.Oo
42.Fl c | Fl h | Fl p |
43.Fl r | Fl k
44.Oc
45.Oo
46.Fl o
47.Op Fl n
48.Oc
49.Ar time
50.Op Ar warning-message ...
51.Nm poweroff
52.Sh DESCRIPTION
53The
54.Nm
55utility provides an automated shutdown procedure for super-users
56to nicely notify users when the system is shutting down,
57saving them from system administrators, hackers, and gurus, who
58would otherwise not bother with such niceties.
59In order to use the
60.Nm
61command, the user must have root privileges or be a member of the
62operator group.
63.Pp
64The following options are available:
65.Bl -tag -width indent
66.It Fl c
67The system is power cycled (power turned off and then back on)
68at the specified time.
69If the hardware doesn't support power cycle, the system will be
70rebooted.
71At the present time, only systems with BMC supported by the
72.Xr ipmi 4
73driver that implement this functionality support this flag.
74The amount of time the system is off is dependent on the device
75that implements this feature.
76.It Fl h
77The system is halted at the specified
78.Ar time .
79.It Fl p
80The system is halted and the power is turned off
81(hardware support required, otherwise the system is halted)
82at the specified
83.Ar time .
84.It Fl r
85The system is rebooted at the specified
86.Ar time .
87.It Fl k
88Kick everybody off.
89The
90.Fl k
91option
92does not actually halt the system, but leaves the
93system multi-user with logins disabled (for all but super-user).
94.It Fl o
95If one of the
96.Fl c ,
97.Fl h ,
98.Fl p
99or
100.Fl r
101options are specified,
102.Nm
103will execute
104.Xr halt 8
105or
106.Xr reboot 8
107instead of sending a signal to
108.Xr init 8 .
109.It Fl n
110If the
111.Fl o
112option is specified, prevent the file system cache from being flushed by passing
113.Fl n
114to
115.Xr halt 8
116or
117.Xr reboot 8 .
118This option should probably not be used.
119.It Ar time
120.Ar Time
121is the time at which
122.Nm
123will bring the system down and
124may be the case-insensitive word
125.Ar now
126(indicating an immediate shutdown) or
127a future time in one of two formats:
128.Ar +number ,
129or
130.Ar yymmddhhmm ,
131where the year, month, and day may be defaulted
132to the current system values.
133The first form brings the system down in
134.Ar number
135minutes and the second at the absolute time specified.
136.Ar +number
137may be specified in units other than minutes by appending the corresponding
138suffix:
139.Dq Li s ,
140.Dq Li sec ,
141.Dq Li m ,
142.Dq Li min ,
143.Dq Li h ,
144.Dq Li hour .
145.Pp
146If an absolute time is specified, but not a date,
147and that time today has already passed,
148.Nm
149will assume that the same time tomorrow was meant.
150(If a complete date is specified which has already passed,
151.Nm
152will print an error and exit without shutting the system down.)
153.It Ar warning-message
154Any other arguments comprise the warning message that is broadcast
155to users currently logged into the system.
156.It Fl
157If
158.Sq Fl
159is supplied as an option, the warning message is read from the standard
160input.
161.El
162.Pp
163At intervals, becoming more frequent as apocalypse approaches
164and starting at ten hours before shutdown, warning messages are displayed
165on the terminals of all users logged in.
166Five minutes before
167shutdown, or immediately if shutdown is in less than 5 minutes,
168logins are disabled by creating
169.Pa /var/run/nologin
170and copying the
171warning message there.
172If this file exists when a user attempts to
173log in,
174.Xr login 1
175prints its contents and exits.
176The file is
177removed just before
178.Nm
179exits.
180.Pp
181At shutdown time a message is written to the system log, containing the
182time of shutdown, the person who initiated the shutdown and the reason.
183The corresponding signal is then sent to
184.Xr init 8
185to respectively halt, reboot or bring the system down to single-user state
186(depending on the above options).
187The time of the shutdown and the warning message
188are placed in
189.Pa /var/run/nologin
190and should be used to
191inform the users about when the system will be back up
192and why it is going down (or anything else).
193.Pp
194A scheduled shutdown can be canceled by killing the
195.Nm
196process (a
197.Dv SIGTERM
198should suffice).
199The
200.Pa /var/run/nologin
201file that
202.Nm
203created will be removed automatically.
204.Pp
205When run without options, the
206.Nm
207utility will place the system into single user mode at the
208.Ar time
209specified.
210.Pp
211Calling
212.Dq Nm poweroff
213is equivalent to running:
214.Bd -literal -offset indent
215shutdown -p now
216.Ed
217.Sh FILES
218.Bl -tag -width /var/run/nologin -compact
219.It Pa /var/run/nologin
220tells
221.Xr login 1
222not to let anyone log in
223.El
224.Sh EXAMPLES
225Reboot the system in 30 minutes and display a warning message on the terminals
226of all users currently logged in:
227.Pp
228.Dl # shutdown -r +30 \&"System will reboot\&"
229.Sh COMPATIBILITY
230The hours and minutes in the second time format may be separated by
231a colon (``:'') for backward compatibility.
232.Sh SEE ALSO
233.Xr kill 1 ,
234.Xr login 1 ,
235.Xr wall 1 ,
236.Xr nologin 5 ,
237.Xr halt 8 ,
238.Xr init 8 ,
239.Xr reboot 8
240.Sh HISTORY
241A
242.Nm
243command was originally written by Ian Johnstone for UNSW's modified
244.At "6th Edn" .
245It was modified and then incorporated in
246.Bx 4.1 .
247