xref: /freebsd/sbin/shutdown/shutdown.8 (revision 7937bfbc0ca53fe7cdd0d54414f9296e273a518e)
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.Dd August 4, 2024
29.Dt SHUTDOWN 8
30.Os
31.Sh NAME
32.Nm shutdown ,
33.Nm poweroff
34.Nd "close down the system at a given time"
35.Sh SYNOPSIS
36.Nm
37.Op Fl
38.Oo
39.Fl c | Fl h | Fl p |
40.Fl r | Fl k
41.Oc
42.Oo
43.Fl o
44.Op Fl n
45.Oc
46.Op Fl q
47.Ar time
48.Op Ar warning-message ...
49.Nm poweroff
50.Sh DESCRIPTION
51The
52.Nm
53utility provides an automated shutdown procedure for super-users
54to nicely notify users when the system is shutting down,
55saving them from system administrators, hackers, and gurus, who
56would otherwise not bother with such niceties.
57In order to use the
58.Nm
59command, the user must have root privileges or be a member of the
60operator group.
61.Pp
62The following options are available:
63.Bl -tag -width indent
64.It Fl c
65The system is power cycled (power turned off and then back on)
66at the specified time.
67If the hardware doesn't support power cycle, the system will be
68rebooted.
69At the present time, only systems with BMC supported by the
70.Xr ipmi 4
71driver that implement this functionality support this flag.
72The amount of time the system is off is dependent on the device
73that implements this feature.
74.It Fl h
75The system is halted at the specified
76.Ar time .
77.It Fl p
78The system is halted and the power is turned off
79(hardware support required, otherwise the system is halted)
80at the specified
81.Ar time .
82.It Fl r
83The system is rebooted at the specified
84.Ar time .
85.It Fl k
86Kick everybody off.
87The
88.Fl k
89option
90does not actually halt the system, but leaves the
91system multi-user with logins disabled (for all but super-user).
92.It Fl o
93If one of the
94.Fl c ,
95.Fl h ,
96.Fl p
97or
98.Fl r
99options are specified,
100.Nm
101will execute
102.Xr halt 8
103or
104.Xr reboot 8
105instead of sending a signal to
106.Xr init 8 .
107.It Fl n
108If the
109.Fl o
110option is specified, prevent the file system cache from being flushed by passing
111.Fl n
112to
113.Xr halt 8
114or
115.Xr reboot 8 .
116This option should probably not be used.
117.It Fl q
118Shut down quietly.
119Suppress the warning message to all logged in users about system shutdown.
120It is an error to supply a
121.Ar warning-message
122when warnings are suppressed.
123.It Ar time
124.Ar Time
125is the time at which
126.Nm
127will bring the system down and
128may be the case-insensitive word
129.Ar now
130(indicating an immediate shutdown) or
131a future time in one of two formats:
132.Ar +number ,
133or
134.Ar yymmddhhmm ,
135where the year, month, and day may be defaulted
136to the current system values.
137The first form brings the system down in
138.Ar number
139minutes and the second at the absolute time specified.
140.Ar +number
141may be specified in units other than minutes by appending the corresponding
142suffix:
143.Dq Li s ,
144.Dq Li sec ,
145.Dq Li m ,
146.Dq Li min ,
147.Dq Li h ,
148.Dq Li hour .
149.Pp
150If an absolute time is specified, but not a date,
151and that time today has already passed,
152.Nm
153will assume that the same time tomorrow was meant.
154(If a complete date is specified which has already passed,
155.Nm
156will print an error and exit without shutting the system down.)
157.It Ar warning-message
158Any other arguments comprise the warning message that is broadcast
159to users currently logged into the system.
160.It Fl
161If
162.Sq Fl
163is supplied as an option, the warning message is read from the standard
164input.
165.El
166.Pp
167At intervals, becoming more frequent as apocalypse approaches
168and starting at ten hours before shutdown, warning messages are displayed
169on the terminals of all users logged in.
170Five minutes before
171shutdown, or immediately if shutdown is in less than 5 minutes,
172logins are disabled by creating
173.Pa /var/run/nologin
174and copying the
175warning message there.
176If this file exists when a user attempts to
177log in,
178.Xr login 1
179prints its contents and exits.
180The file is
181removed just before
182.Nm
183exits.
184.Pp
185At shutdown time a message is written to the system log, containing the
186time of shutdown, the person who initiated the shutdown and the reason.
187The corresponding signal is then sent to
188.Xr init 8
189to respectively halt, reboot or bring the system down to single-user state
190(depending on the above options).
191The time of the shutdown and the warning message
192are placed in
193.Pa /var/run/nologin
194and should be used to
195inform the users about when the system will be back up
196and why it is going down (or anything else).
197.Pp
198A scheduled shutdown can be canceled by killing the
199.Nm
200process (a
201.Dv SIGTERM
202should suffice).
203The
204.Pa /var/run/nologin
205file that
206.Nm
207created will be removed automatically.
208.Pp
209When run without options, the
210.Nm
211utility will place the system into single user mode at the
212.Ar time
213specified.
214.Pp
215Calling
216.Dq Nm poweroff
217is equivalent to running:
218.Bd -literal -offset indent
219shutdown -p now
220.Ed
221.Sh FILES
222.Bl -tag -width /var/run/nologin -compact
223.It Pa /var/run/nologin
224tells
225.Xr login 1
226not to let anyone log in
227.El
228.Sh EXAMPLES
229Reboot the system in 30 minutes and display a warning message on the terminals
230of all users currently logged in:
231.Pp
232.Dl # shutdown -r +30 \&"System will reboot\&"
233.Sh COMPATIBILITY
234The hours and minutes in the second time format may be separated by
235a colon (``:'') for backward compatibility.
236.Sh SEE ALSO
237.Xr kill 1 ,
238.Xr login 1 ,
239.Xr wall 1 ,
240.Xr nologin 5 ,
241.Xr halt 8 ,
242.Xr init 8 ,
243.Xr reboot 8
244.Sh HISTORY
245A
246.Nm
247command was originally written by Ian Johnstone for UNSW's modified
248.At "6th Edn" .
249It was modified and then incorporated in
250.Bx 4.1 .
251