<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="shutdown">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>shutdown</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo class="manual">administrator commands</refmiscinfo>
<refmiscinfo class="source">nosh</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv>
<refname>shutdown</refname>
<refpurpose>BSD/System 5 compatibility utility for system shutdown</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>shutdown</command>
<arg choice="opt">--verbose</arg>
<group choice="opt">
<arg choice="plain">--halt</arg>
<arg choice="plain">-H</arg>
<arg choice="plain">-h</arg>
</group>
<group choice="opt">
<arg choice="plain">--powercycle</arg>
<arg choice="plain">-c</arg>
</group>
<group choice="opt">
<arg choice="plain">--poweroff</arg>
<arg choice="plain">-P</arg>
<arg choice="plain">-p</arg>
</group>
<group choice="opt">
<arg choice="plain">--reboot</arg>
<arg choice="plain">-r</arg>
</group>
<group choice="opt">
<arg choice="plain">--kick-off</arg>
<arg choice="plain">-k</arg>
</group>
<arg choice="opt">--no-wall</arg>
<group choice='req'>
<arg choice="plain">-g <replaceable>period</replaceable></arg>
<arg choice="plain"><replaceable>time</replaceable></arg>
</group>
<arg choice="opt" rep="repeat"><replaceable>message</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>Description</title>

<para>
<command>shutdown</command> shuts down the system, optionally waiting for a period and sending warnings to the terminals of logged-in users before calling <citerefentry><refentrytitle>system-control</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
</para>

<para>
<command>shutdown</command> waits for a period, sending warning messages to logged-on user terminals with <citerefentry><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry>, and then chains to the <arg choice='req'>powercycle</arg>, <arg choice='req'>poweroff</arg>, <arg choice='req'>halt</arg>, or <arg choice='req'>reboot</arg> subcommands of <citerefentry><refentrytitle>system-control</refentrytitle><manvolnum>1</manvolnum></citerefentry> to instruct the system manager to enact a state change.
The default, if no option is specified, is to power off.
</para>

<para>
No checks are made to see whether the current user has permission to send messages to terminals, or to enact system state changes.
The <citerefentry><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>system-control</refentrytitle><manvolnum>1</manvolnum></citerefentry> commands are expected to perform all permissions checks.
</para>

<para>
The warning messages comprise an indication of the impending system state change and how soon it will occur, plus whatever additional message text is supplied as <arg choice='plain' rep='repeat'><replaceable>message</replaceable></arg>.
They can be disabled with the <arg choice='plain'>--no-wall</arg> option.
</para>

<para>
The messages are sent during the period before the scheduled shutdown time, beginning at 86400 seconds beforehand.
They are sent at 6-hourly intervals until the final 6 hours, at hourly intervals until the final hour, at 15-minute intervals until the final 15 minutes, at 5-minute intervals until the final 5 minutes, at 1 minute intervals until the final minute, at 15-second intervals until the final 15 seconds, and finally when the scheduled time is reached (or passed).
</para>

<para>
When to shutdown must be specified either with a command line option or an argument:
</para>
<itemizedlist>
<listitem><para>
The <arg choice='plain'>-g</arg> (grace period) command line option specifies when with a relative time.
It can be:
</para>
<variablelist>
<varlistentry>
<term><arg choice='plain'>now</arg></term>
<listitem><para>
This specifies no delay to shutdown.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'><replaceable>hours</replaceable>:<replaceable>minutes</replaceable></arg></term>
<listitem><para>
Shutdown scheduled for <replaceable>hours</replaceable> &#x00d7; 60 + <replaceable>minutes</replaceable> minutes from now.
<replaceable>minutes</replaceable> may be greater than 60; <replaceable>hours</replaceable> may be greater than 24.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'><replaceable>minutes</replaceable></arg></term>
<listitem><para>
Shutdown scheduled for <replaceable>minutes</replaceable> minutes from now.
</para></listitem>
</varlistentry>
</variablelist>
</listitem>
<listitem><para>
<replaceable>time</replaceable> is a time specifier for either a relative or an absolute time.
It can be:
</para>
<variablelist>
<varlistentry>
<term><arg choice='plain'>now</arg></term>
<listitem><para>
This specifies no delay to shutdown.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>+<replaceable>minutes</replaceable></arg></term>
<listitem><para>
Shutdown scheduled for <replaceable>minutes</replaceable> minutes from now.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'><replaceable>HH</replaceable>:<replaceable>MM</replaceable></arg></term>
<listitem><para>
Shutdown scheduled for <replaceable>HH</replaceable>:<replaceable>MM</replaceable> today.
This must be now or in the future; and a valid time.
It is an absolute time that is not to be confused with the relative time used with the <arg choice='plain'>-g</arg> command line option.
</para><caution>
The old BSD <command>shutdown</command> command considers this to be a backwards compatibility syntax, which is undocumented in its manual.
Because of that, and also because of the potential confusion with the (in contrast, documented by AT&amp;T System 5) grace period syntax, use of this form of absolute time is strongly discouraged.
</caution></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'><arg choice='opt'><arg choice='opt'><arg choice='opt'><arg choice='opt'><arg choice='opt'><replaceable>CC</replaceable></arg><replaceable>YY</replaceable></arg><replaceable>MM</replaceable></arg><replaceable>DD</replaceable></arg><replaceable>HH</replaceable></arg><replaceable>MM</replaceable></arg></term>
<listitem><para>
Shutdown scheduled for the given time, assuming the current century, year, month, and day as necessary.
This must be now or in the future.
</para></listitem>
</varlistentry>
</variablelist>
</listitem>
</itemizedlist>

<para>
The final state change request can be disabled with the <arg choice='plain'>--kick-off</arg> option.
Its name derives from the notion that one can perform a partial switch to (the old) "single-user" mode which only logs out interactive users, kicking them off the system, although this mechanism has been superseded now that "single-user" mode no longer exists.
</para>

</refsection>

<refsection><title>History and compatibility</title>

<refsection><title>Grace period</title>

<para>
The upstart and old BSD <command>shutdown</command> commands require that the time to shutdown always be specified, aborting if it is not; others default to 1 minute from now in the absence of any specification.
</para>

<para>
Both the XENIX and UnixWare, and the upstart, old BSD, and systemd ways of specifying when to shut down are supported.
In order to avoid embarrassment resulting from unexpected defaults, explicitly specifying when shutdown should occur is mandatory.
</para>

</refsection>

<refsection><title>Warning message intervals</title>

<para>
The upstart, old BSD, van SmoorenBerg, XENIX, UnixWare, and systemd <command>shutdown</command> commands all have different patterns (from one another) of intervals between warning messages being emitted.
</para>

<para>
In this <command>shutdown</command>, the intervals between warning messages roughly follow the pattern used by the XENIX and UnixWare <command>shutdown</command> commands.
</para>

</refsection>

<refsection><title>Defaults and the obsolete "single-user" mode</title>

<para>
The upstart, old BSD, and van Smoorenberg systems incorporated the notion of shutting down to "single-user" mode, even though (on the BSDs at least) that was not strictly speaking possible as the switch to "multi-user" mode made a one-way change to the kernel secure level.
As a consequence, their <command>shutdown</command> commands had the following semantics:
</para>
<itemizedlist>
<listitem><para>
With no options, the default action was to (attempt to) transition to "single-user" mode.
</para></listitem>
<listitem><para>
The <arg choice='plain'>-r</arg>, <arg choice='plain'>-h</arg>, and (in the old BSD system) <arg choice='plain'>-p</arg> options overrode that to select reboot, halt, or poweroff.
</para> <note>
In the upstart and van Smoorenberg systems the <arg choice='plain'>-h</arg> option was actually halt/poweroff, and would require the <arg choice='plain'>-H</arg> and <arg choice='plain'>-P</arg> options to further choose which of halt or poweroff was selected, the default being determined by the capabilities of the operating system and platform (which might not support software power off).
In the old BSD system the <arg choice='plain'>-h</arg> and <arg choice='plain'>-p</arg> options were just halt and poweroff directly.
</note></listitem>
</itemizedlist>

<para>
There is no "single-user" mode now.
Neither <citerefentry><refentrytitle>system-control</refentrytitle><manvolnum>1</manvolnum></citerefentry> nor systemd encompass any such thing, and it was in fact also superseded in the van Smoorenberg system in 1995.
Its replacements <ulink url="https://jdebp.uk/FGA/emergency-and-rescue-mode-bootstrap.html">since the 1990s</ulink> have been and are the <filename>emergency</filename> and <filename>rescue</filename> targets, described in <citerefentry><refentrytitle>system-control</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
These are <emphasis>startup</emphasis> targets that are not reachable via <emphasis>shutdown</emphasis> procedures.
</para>

<para>
As a consequence, poweroff is now the default action and the compatibility behaviour is as follows:
</para>
<itemizedlist>
<listitem><para>
The <arg choice='plain'>-p</arg> and <arg choice='plain'>-P</arg> options are considered to be on by default, and thus have no effect.
</para></listitem>
<listitem><para>
The <arg choice='plain'>-r</arg>, <arg choice='plain'>-h</arg>, and <arg choice='plain'>-H</arg> options select the non-default actions.
</para></listitem>
</itemizedlist>

<para>
UnixWare supported a <arg choice="plain">su</arg> command-line argument.
This was <emphasis>itself</emphasis> a backwards-compatibility mechanism for the <command>shutdown</command> command in XENIX, the UnixWare command having a different syntax involving an <arg choice="plain">-i</arg> commmand-line option and "run levels".
Neither command-line syntax was provided by the old BSD, van Smoorenberg, upstart, or systemd <command>shutdown</command> comands.
</para>

<para>
Not only is there no "single-user" mode now, <ulink url="https://jdebp.uk/FGA/run-levels-are-history.html">run levels have been obsolete in the AT&amp;T Unix world since the 1980s</ulink> and UnixWare had switched to the Service Access Facility.
Therefore, this <command>shutdown</command> likewise does not provide this XENIX syntax that translates a then-obsolete thing into something that was <emphasis>also then</emphasis> largely obsolete.
</para>

</refsection>

<refsection><title>Command line options from old toolsets and other defunct mechanisms</title>

<para>
The <command>shutdown</command> commands from old toolsets also variously wrote flag files, directly enacted system state changes, bypassed filesystem unmounts and cache flushes, triggered kernel dumps, and had interactive modes where they asked the initiator what xe wanted to do.
The flags for these things are either errors or simply ignored:
</para>

<variablelist>
<varlistentry>
<term><arg choice='plain'>-y</arg></term>
<listitem><para>
This AT&amp;T System 5 option is an error.
It was recommended to use non-interactive mode in AT&amp;T System 5 guides in the 1980s; and <command>shutdown</command> commands that outright lacked an interactive mode became common in the 1990s.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>-f</arg></term>
<term><arg choice='plain'>-F</arg></term>
<listitem><para>
These van Smoorenberg options are errors.
Flag files, written to a potentially corrupt or dirty volume, are no longer the way to invoke or to bypass filesystem checks.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>-o</arg></term>
<listitem><para>
This BSD option is ignored.
All system state changes are enacted by process #1, usually running <citerefentry><refentrytitle>system-manager</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
None are enacted directly.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>-n</arg></term>
<listitem><para>
This van Smoorenberg and BSD option is an error.
It is not permitted to bypass the filesystem cache flush, which is an integral part of the actions taken by <citerefentry><refentrytitle>system-manager</refentrytitle><manvolnum>1</manvolnum></citerefentry> at shutdown.
The van Smoorenberg system in fact deprecated this mechanism in the 1990s.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>-t</arg></term>
<listitem><para>
This van Smoorenberg option is an error.
Service termination intervals are not adjustable via the <command>shutdown</command> command.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>-d</arg></term>
<listitem><para>
This OpenBSD option is an error.
Kernel dumps not triggerable via the <command>shutdown</command> command.
</para></listitem>
</varlistentry>
</variablelist>

</refsection>

</refsection>

<refsection><title>Author</title>
<para><author><personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname></author></para>
</refsection>

</refentry>
