s6-linux-init
Software
skarnet.org

# The `s6-linux-init-shutdown` program

`s6-linux-init-shutdown` triggers the system shutdown procedure. It is normally invoked as `/sbin/shutdown`.

## Interface

         s6-linux-init-shutdown [ -h [ -H | -P ] | -p | -r | -k ] [ -a ] [ -t sec ] [ -i ] [ -f | -F ] time [ message ]
         s6-linux-init-shutdown -c [ message ]

- If the `-c` option is present, a pending shutdown is cancelled.
- Else, it plans the shutdown procedure at time time.
- If a message argument has been given, message is broadcast to all logged in users (as tracked by utmp).
- `shutdown` exits 0. The shutdown procedure happens asynchronously.

The `s6-linux-init-shutdown` program conforms to the LSB-3.0.0 shutdown interface.

time must follow the following format: `[ now | [+]mins | hh:mm ]`

- `now` means: trigger the shutdown sequence immediately.
- hh:mm means: absolute time. Trigger the shutdown sequence when the time hh:mm occurs. If that time has passed for the day, it will wait for the next day. hh must have 1 or 2 digits; mm must have 2 digits.
- mins or `+`mins means: relative time. Trigger the shutdown sequence after mins minutes.

## Options

- `-a` : access control. The shutdown sequence will only be launched if one of the users listed in `/etc/shutdown.allow` is currently logged in (as tracked by utmp). `/etc/shutdown.allow` is a text file, one user per line, lines starting with `#` are comments.
- `-t` sec : at the end of the shutdown sequence, when it's time to kill all processes, have a "grace time" period of sec seconds between the SIGTERM and the SIGKILL (to allow processes receiving SIGTERM to exit cleanly). Default is 3 seconds.
- `-k` : warning only. message will be sent to all logged in users, but the shutdown sequence will not be triggered.
- `-h` : at the end of the shutdown sequence, halt the system. The behaviour of this option may be altered with `-H` or `-P`.
- `-p` : at the end of the shutdown sequence, power off the system. (This option is provided as an extension, it is not required by the LSB interface.)
- `-r` : at the end of the shutdown sequence, reboot the system.
- `-f` : ignored.
- `-F` : ignored.
- `-c` : cancel a planned shutdown (i.e. cancel the effect of a previous call to `shutdown` with a time argument that was not `now`). This cannot be used to interrupt a shutdown sequence that has already started.
- `-H` : this option can only be used in conjunction with `-h`. Ensures the system is halted, not powered off, at the end of the shutdown sequence. `-Hh` is equivalent to `-h`.
- `-P` : this option can only be used in conjunction with `-h`. Ensures the system is powered off at the end of the shutdown sequence. `-Ph` is equivalent to `-p`.
- `-i` : interactive confirmation request. The command needs to be launched in a terminal, and will prompt the user to type the (short) hostname of the machine to be shut down. On mismatch, the command will abort. The point is to avoid inadvertently rebooting a remote machine in an ssh session.

## Notes

- The `s6-linux-init-shutdown` binary is not meant to be called directly by administrators. Instead, after a s6-linux-init-maker invocation, the `bin/` subdirectory of the target will contain a `shutdown` symlink to `s6-linux-init-shutdown`. The `bin/` subdirectory should be copied by the administrator into `/sbin` for full interface compatibility with sysvinit.
- The `-f` and `-F` options are only accepted for compatibility. LSB says they are used to advise the system to skip or enforce a `fsck` after rebooting. But they are only advisory, and for decades now systems have used other methods of evaluating whether they should perform filesystem checks, so these options are largely obsolete nowadays.