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