Close down the system at a given time.
Shutdown provides an automated shutdown procedure for super-users to nicely
notify users when the system is shutting down, saving them from system administrators,
hackers, and gurus, who would otherwise not bother with such niceties.
Syntax
shutdown [-] [-h [-u] | -r | -s | -k] [-o [-n]] time [warning-message ...]
Key
-h Halt macOS at the specified time (shutdown with no restart).
-k Kick everybody off. The -k option does not actually halt the system, but leaves
the system multi-user with logins disabled (for all but super-user).
-n If the -o is specified, prevent the file system cache from being flushed by passing the
-n option to halt(8) or reboot(8). This option should probably not be used.
-o If -h or -r is specified, shutdown will execute halt(8) or reboot(8) instead of
sending a signal to launchd(8).
-q Shut down quietly. Suppress the warning message to all logged in users about system shutdown.
It is an error to supply a warning-message when warnings are suppressed.
-r Reboot macOS at the specified time.
-s Sleep macOS at the specified time.
-u The system is halted up until the point of removing system power, but waits
before removing power for 5 minutes so that an external UPS (uninterruptible
power supply) can forcibly remove power. This simulates a dirty shutdown to permit
a later automatic power on. macOS uses this mode automatically with supported
UPSs in emergency shutdowns.
time The time at which shutdown will bring the system down and may be the word now
(indicating an immediate shutdown) or specify a future time in one of two formats:
+number, or yymmddhhmm, where the year, month, and day may be defaulted
to the current system values.
The first form brings the system down in number minutes and the second at the
absolute time specified.
+number may be specified in units other than minutes by appending the corresponding
suffix: “s”, “sec”, “m”, “min”, “h”, “hour”.
If an absolute time is specified, but not a date, and that time today has already passed,
shutdown will assume that the same time tomorrow was meant. (If a complete date is
specified which has already passed, shutdown will print an error and exit without
shutting the system down.)
warning-message
Any other arguments comprise the warning message that is broadcast to users
currently logged into the system.
- If '-' is supplied as an option, the warning message is read from standard input.
At intervals, becoming more frequent as apocalypse approaches and starting at ten hours before shutdown, warning messages are displayed on the terminals of all users logged in.
Five minutes before shutdown, or immediately if shutdown is in less than 5 minutes, logins are disabled by creating /var/run/nologin and copying the warning message there. If this file exists when a user attempts to log in, login(1)
prints its contents and exits. The file is removed just before shutdown exits.
At shutdown time a message is written in the system log, containing the time of shutdown, who initiated the shutdown and the reason. A terminate signal is then sent to launchd to bring the system down to single-user state (depending on above options).
A scheduled shutdown can be canceled by killing the shutdown process (a SIGTERM should suffice).
When run without options, the shutdown utility will place the system into single user mode at the time specified.
The hours and minutes in the second time format may be separated by a colon : for backward compatibility.
FILES
/etc/nologin tells login not to let anyone log in
/fastboot tells rc(8) not to run fsck when rebooting
/usr/libexec/upsshutdown - Run a command when the UPS shuts down.
Reboot the machine immediately:
$ sudo shutdown -r now
Send the machine to sleep in 30 minutes from now:
$ sudo shutdown -s +30
Shutdown ⏻ the machine in 60 minutes:
$ sudo shutdown -h +60
Cancel any of the above:
$ sudo killall shutdown
“Do all men kill the things they do not love?” ~ The Merchant of Venice
Local man page: shutdown - Command line help page on your local machine.
kill - Stop a process from running.
login - log into the computer.
osascript - shutdown/restart via AppleScript.
pmset - sleep now.
sudo poweroff
wall - write a message to users.
fastboot(8)
reboot - Stop and restart the system.
uptime - Show how long system has been running.