Linux 关机命令 All In One
raspberry pi 关机命令
# 关闭电源
$ sudo poweroff
# 立即关机
$ sudo shutdown -h now
# 等价于
$ sudo shutdown -h +0
# 立即重启
$ sudo shutdown -r now
# 等价于
$ sudo shutdown -r +0
# 取消关机
$ sudo shutdown -c
-h === host
-r === reboot
-c === cancel
# 3 分钟后自动关机,并且广播提醒所有用户 ⚠️
$ sudo shutdown -h +3 " 3 分钟后关机, 请提前做好文件保存!"
# 等价于 `hh:mm`
$ sudo shutdown -h 00:03 " 3 分钟后关机, 请提前做好文件保存!"
# 3 分钟后自动重启,并且广播提醒所有用户 ⚠️
$ sudo shutdown -r +3 " 3 分钟后重启, 请提前做好文件保存!"
# 取消自动关机,并且广播提醒所有用户 ⚠️
$ sudo shutdown -c "Canceling the reboot"
macOS
$ sudo shutdown -h
# usage: shutdown [-] [-h [-u] [-n] | -r [-n] | -s | -k] time [warning-message ...]
# shutdown [OPTIONS] [TIME] [MESSAGE]
How To Shutdown Linux Using Command Line
$ su -
# or
$ sudo -s
# root password
$ shutdown -h now
# OR
$ shutdown -h +0
$ sudo systemctl poweroff
#
$ sudo poweroff
Reboot Linux system command syntax
The syntax is:
shutdown -h time "message"
Where,
-h
: Poweroff the system.
time
: When to shutdown. You can poweroff immediately or after 2 minutes.
It can be an absolute time in the format hh:mm
, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in two digits).
Second, it can be in the format +m
, in which m is the number of minutes
to wait.
The word now
is an alias for +0
.
message
: Send warning message to send to all users.
man
$ man shutdown
# OR
$ man 8 shutdown
supported UPSs in emergency shutdowns.
time Time is 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.
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 the
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.
At shutdown time a message is written to the system log, containing the time of
shutdown, the person who initiated the shutdown and the reason. Corresponding
signal is then sent to launchd(8) to respectively halt, reboot or bring the system
down to single-user state (depending on the above options).
A scheduled shutdown can be canceled by killing the shutdown process (a SIGTERM
should suffice).
SIGTERM TO SIGKILL INTERVAL
Upon shutdown, all running processes are sent a SIGTERM followed by a SIGKILL. The
SIGKILL will follow the SIGTERM by an intentionally indeterminate period of time.
Programs are expected to take only enough time to flush all dirty data and exit.
Developers are encouraged to file a bug with the OS vendor, should they encounter an
issue with this functionality.
SEE ALSO
kill(1), login(1), wall(1), halt(8), launchd(8), reboot(8)
BACKWARD COMPATIBILITY
The hours and minutes in the second time format may be separated by a colon (``:'')
for backward compatibility.
HISTORY
The shutdown utility appeared in 4.0BSD.
macOS 12.3 December 11, 1998 macOS 12.3
$ last shutdown
shutdown ~ Fri Jul 1 22:10
shutdown ~ Thu Jun 30 10:03
shutdown ~ Fri Jun 24 22:10
shutdown ~ Wed Jun 22 16:32
shutdown ~ Fri Jun 10 22:10
shutdown ~ Fri May 20 22:10
shutdown ~ Fri Apr 22 22:10
shutdown ~ Tue Apr 12 02:45
wtmp begins Wed Mar 30 07:58
LEMP
PHP
https://www.cnblogs.com/xgqfrms/p/5361895.html
refs
https://www.cyberciti.biz/faq/howto-shutdown-linux/
https://linuxize.com/post/linux-shutdown-command/
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 ️,侵权必究⚠️!