Skip to content

Add time argument and wall message to shutdown #149

@troglobit

Description

@troglobit

Currently shutdown is just another multicall symlink to reboot. The options have been mapped to allow for a command like shutdown -h now, but the 'now' argument is ignored,

Syntax: shutdown [opts] [timefmt] [wallmsg]

The timefmt is either of two formats +M or HH:MM, where H is hour and M minute. The now keyword is shorthand for +0. If timefmt evaluates to a a time >15 minutes, no action is taken and shutdown simply waits in the foreground until its 15 minutes left.

The wallmsg can be anything and is, along with the reboot/shutdow message, written to the file /etc/nologin, which in turn is used by other daemons to prevent users other than root to log in. This file is not created if timefmt evaluates to a time >15 minutes, as mentioned above.

When there is <= 15 minutes left to shutdown/reboot the following message is printed to the TTY of each logged in user:

Broadcast message from root (ttyN) (Sun Feb 14 02:25:28 2021):

wallmsg
The system is going DOWN for system halt in M minutes!

If no wallmsg is given and reboot has been selected:

Broadcast message from root (ttyN) (Sun Feb 14 02:25:28 2021):

The system is going DOWN for reboot in M minutes!

Just before shutdown calls init to perform the action, the following message is printed:

Broadcast message from root (ttyN) (Sun Feb 14 02:25:28 2021):

The system is going DOWN for reboot NOW!

When shutdown is called with a timefmt that evaluates to >0 minutes it can be canceled. This can be done by calling shutdown -c in another TTY. The PID of the active shutdown is available in /var/run/shutdown.pid, which also acts as a lock preventing other users to call shutdown without cancelling the active one first. Ctrl-C (SIGINT) on the active shutdown TTY also disables the countdown. When shutdown exits due to cancellation it also removes /etc/nologin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions