Introduction to Commands
Shutdown,poweroff,reboot,halt,init can be shut down for general use.
/sbin/halt [-N] [-W] [-d] [-f] [-i] [-p] [-h]
/sbin/reboot [-N] [-W] [-d] [-f] [-I.]
/sbin/poweroff [-N] [-W] [-d] [-f] [-i] [-h]
[email protected] ~]$ reboot--h
Usage:reboot [-N] [-W] [-d] [-f] [-h] [-I.]
-N: not synchronized before stopping the system
-W: Write only wtmp reboot record and leave
-D: Do not write Wtmp records
-F: Forced shutdown or restart
-H: Leave the hard drive in stand-alone mode
-I: Turn off all network interfaces
Shutdown process
1. Flush the hard disk cache:
2. Log restart Event: (/var/run/utmp,/var/log/wtmp)
3. Kill All Processes:
4. Finally restart the machine:
Example of shutting down the machine
# shutdown-h Now #立刻关机
# shutdown-h ' Halt ' #2点30分关机, pay attention to the time of the machine
# halt-p #立刻关机
# init 0 #立即将系统运行级别切换为0, i.e. shutdown
# Shutdown-r Now #立刻重启
Restart Example
# shutdown-k Now ' reboot ' #发出警告讯息, but without really shutting down the machine.
# shutdown-t10-r now #立刻重启, but between warning and deleting processes, the delay is 10 seconds.
# init 6 #立即将系统运行级别切换为6, restart
# shutdown-r +10 ' reboot ' #10分钟后重启
# shutdown-c #取消之前的shutdown命令
# Shutdown now #切换至单人操作模式 (when no option is added)
Shutdown preparation
Linux is no more than Windows, and if it does not shut down properly, it may cause file system corruption because it is too late to write data back to the file. So before shutting down, pay attention to:
1. Observing the System status
- View online users with the WHO command
- View Network online status with the Netstat-a command
- Use PS aux command to view background execution program
2. Notify online users #shutdown-k now ' System would reboot in minutes! '
3. Use the correct command #首先要搞清楚是关机还是重启, and then note the parameters
4. Note The data synchronization #使用sync数据同步写入磁盘
Other Notes
1. View Restart record
# last Reboot
2. Remote Boot machine
# ssh [email Protected]/sbin/reboot
# SSH [email protected]/sbin/shutdown-r now