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