View the usage status of the system
1、Use the WHO command to view online users.
2、Use netstat-a or ss-tnl to view network status:
3、Use ps-aux to view programs running in the background.
Through the above operation, we can know the current use status of the system, and then judge whether it can be shut down.
Notify online users of shutdown time
Write data to disk synchronously
syncCommand: Just enter sync directly. Write data in memory to disk. It’s better to execute more than once.
Restart or shutdown
shutdownIt has the following functions:
Free choice shutdown mode: shutdown, restart or enter single user mode.
Set the shutdown time: Set the shutdown time immediately or at a certain time.
You can customize shutdown messages: before shutdown, send settings messages to online users.
You can only issue warning messages: only send warning messages if you don’t really shut down.
You can choose whether you need fsck to check the file system.
-t sec：-tLater plus seconds, meaning “shut down after a few seconds”
-k：Not really shut down until a warning message is sent
shutdown -k now “The system will be restarted”: Send back messages to online users
shutdown -r now：Restart now
shutdown -r +10 “System restart after 10 minutes”: Restart in another 10 minutes and send the message back to the online user
-h：Shut down the system immediately after the service is shut down
shutdown -h now ：shutdown -h now
shutdown -h 20:20：Turn off at 20:20 today
shutdown -h +10：10Automatic shutdown in minutes
-f：Force to skip fsck disk checking after shutdown and boot-up
-F：Force fsck disk checking after shutdown and boot-up
-c：Cancel the shutdown command content already in progress