xref: /freebsd/sbin/shutdown/shutdown.8 (revision 24e4dcf4ba5e9dedcf89efd358ea3e1fe5867020)
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 f | 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 f
75The
76.Nm
77command ignores the presence of the
78.Pa /var/run/noshutdown
79file.
80.It Fl h
81The system is halted at the specified
82.Ar time .
83.It Fl p
84The system is halted and the power is turned off
85(hardware support required, otherwise the system is halted)
86at the specified
87.Ar time .
88.It Fl r
89The system is rebooted at the specified
90.Ar time .
91.It Fl k
92Kick everybody off.
93The
94.Fl k
95option
96does not actually halt the system, but leaves the
97system multi-user with logins disabled (for all but super-user).
98.It Fl o
99If one of the
100.Fl c ,
101.Fl h ,
102.Fl p
103or
104.Fl r
105options are specified,
106.Nm
107will execute
108.Xr halt 8
109or
110.Xr reboot 8
111instead of sending a signal to
112.Xr init 8 .
113.It Fl n
114If the
115.Fl o
116option is specified, prevent the file system cache from being flushed by passing
117.Fl n
118to
119.Xr halt 8
120or
121.Xr reboot 8 .
122This option should probably not be used.
123.It Fl q
124Shut down quietly.
125Suppress the warning message to all logged in users about system shutdown.
126It is an error to supply a
127.Ar warning-message
128when warnings are suppressed.
129.It Ar time
130.Ar Time
131is the time at which
132.Nm
133will bring the system down and
134may be the case-insensitive word
135.Ar now
136(indicating an immediate shutdown) or
137a future time in one of two formats:
138.Ar +number ,
139or
140.Ar yymmddhhmm ,
141where the year, month, and day may be defaulted
142to the current system values.
143The first form brings the system down in
144.Ar number
145minutes and the second at the absolute time specified.
146.Ar +number
147may be specified in units other than minutes by appending the corresponding
148suffix:
149.Dq Li s ,
150.Dq Li sec ,
151.Dq Li m ,
152.Dq Li min ,
153.Dq Li h ,
154.Dq Li hour .
155.Pp
156If an absolute time is specified, but not a date,
157and that time today has already passed,
158.Nm
159will assume that the same time tomorrow was meant.
160(If a complete date is specified which has already passed,
161.Nm
162will print an error and exit without shutting the system down.)
163.It Ar warning-message
164Any other arguments comprise the warning message that is broadcast
165to users currently logged into the system.
166.It Fl
167If
168.Sq Fl
169is supplied as an option, the warning message is read from the standard
170input.
171.El
172.Pp
173At intervals, becoming more frequent as apocalypse approaches
174and starting at ten hours before shutdown, warning messages are displayed
175on the terminals of all users logged in.
176Five minutes before
177shutdown, or immediately if shutdown is in less than 5 minutes,
178logins are disabled by creating
179.Pa /var/run/nologin
180and copying the
181warning message there.
182If this file exists when a user attempts to
183log in,
184.Xr login 1
185prints its contents and exits.
186The file is
187removed just before
188.Nm
189exits.
190.Pp
191At shutdown time a message is written to the system log, containing the
192time of shutdown, the person who initiated the shutdown and the reason.
193The corresponding signal is then sent to
194.Xr init 8
195to respectively halt, reboot or bring the system down to single-user state
196(depending on the above options).
197The time of the shutdown and the warning message
198are placed in
199.Pa /var/run/nologin
200and should be used to
201inform the users about when the system will be back up
202and why it is going down (or anything else).
203.Pp
204A scheduled shutdown can be canceled by killing the
205.Nm
206process (a
207.Dv SIGTERM
208should suffice).
209The
210.Pa /var/run/nologin
211file that
212.Nm
213created will be removed automatically.
214.Pp
215If the
216.Pa /var/run/noshutdown
217file is present,
218.Nm
219exits without executing any action on the system.
220.Pp
221When run without options, the
222.Nm
223utility will place the system into single user mode at the
224.Ar time
225specified.
226.Pp
227Calling
228.Dq Nm poweroff
229is equivalent to running:
230.Bd -literal -offset indent
231shutdown -p now
232.Ed
233.Sh FILES
234.Bl -tag -width /var/run/noshutdown -compact
235.It Pa /var/run/nologin
236tells
237.Xr login 1
238not to let anyone log in
239.It Pa /var/run/noshutdown
240prevents
241.Nm
242from initiating an action on the system.
243Can be overridden with the
244.Fl f
245option.
246.El
247.Sh EXAMPLES
248Reboot the system in 30 minutes and display a warning message on the terminals
249of all users currently logged in:
250.Pp
251.Dl # shutdown -r +30 \&"System will reboot\&"
252.Sh COMPATIBILITY
253The hours and minutes in the second time format may be separated by
254a colon (``:'') for backward compatibility.
255.Sh SEE ALSO
256.Xr kill 1 ,
257.Xr login 1 ,
258.Xr wall 1 ,
259.Xr nologin 5 ,
260.Xr halt 8 ,
261.Xr init 8 ,
262.Xr reboot 8
263.Sh HISTORY
264A
265.Nm
266command was originally written by Ian Johnstone for UNSW's modified
267.At "6th Edn" .
268It was modified and then incorporated in
269.Bx 4.1 .
270