Shut down and restart the Linux system

Source: Internet
Author: User
Shutting down a Linux system is different from restarting a desktop system. as a server, we rarely restart a Linux system. However, in the following cases, we will restart the system: www.2cto.com hardware change system configuration the system is frozen and needs to be restarted to recover and shut down and restart the system... shutting down a Linux system is different from restarting a desktop system. as a server, we rarely restart a Linux system. However, in the following cases, we will restart the system: www.2cto.com changing the hardware to change the system configuration the system is frozen. you need to restart, recover, shut down, and restart the system to guide the system. In essence, there are only one way to disable or reboot the system. The difference is that there are multiple methods to shut down or reboot the system: power off (power off) use the shutdown command to use the halt, poweroff, or reboot command www.2cto.com to use telinit to change the init running level to power off the machine for the following two reasons, this is not a good habit: Some data may be damaged by hardware, but may still be stored in the memory and not written back to the disk. in this case, the number of power-off will be lost. Data may cause damage to the file system; therefore, try other methods to shut down or reboot the system. The shutdown command can be used to suspend (halt) or restart (reboot) the system. the-h option is used to indicate that the system is suspended, which plays the same role as the halt command. the-r option is used to indicate that the system is restarted, it serves the same purpose as the reboot command. After the shutdown command is executed, the system sends a pending or restarting message to all login users. After executing shutdown-h now, send a pending message: [SQL] # shutdown-h now Broadcast message from root (tty1) (Thu May 3 10:58:22 2012 ): the system is going down for system halt NOW! INIT: Switching to runlevel: 0 INIT: Sending processes the TERM signal executes shutdown-r now and then sends the Restart message: [SQL] # shutdown-r now Broadcast message from root (tty1) (Thu May 3 11:18:22 2012): The system is going down for system reboot NOW! INIT: Switching to runlevel: 6 INIT: Sending processes the TERM signal after shutdown, other users cannot log on to the system. In addition, we can specify the time and description of system suspension or restart, for the following two examples: downtime maintenance at: [SQL] shutdown-h "going down for scheduled maintenance. expected downtime is 1 hour. "shutdown after a relative shutdown time of 15 minutes: [SQL] shutdown-h + 15" going down for emergency check. "halt and reboot commands halt record shutdown, terminate unnecessary processes, execute the sync system call, wait until the file system write operation is completed, and then stop the kernel. the poweroff command is equivalent to halt. From the output of the above "shutdown-h" and "shutdown-r" execution, we can see that the execution of halt enters the running level 0, and the execution of reboot enters the running level 6, logs are recorded in the/var/log/messages log file. System restart log: [SQL] May 3 11:45:25 slot14 shutdown [11119]: shutting down for system reboot May 3 11:45:25 slot14 init: Switching to runlevel: 6 May 3 11:45:25 slot14 user_cmd: 11:45:25 shutdown-r now by root from [root tty1 May 3 10:50:22] system suspension log: [SQL] May 3 slot14 shutdown [11561]: shutting down for system halt May 3 10:50:22 slot14 init: Switching to runlevel: 0 May 3 10:50:22 slot14 us Er_cmd: 10:50:22 shutdown-h now by root from [root tty1 May 3] by checking the/var/log/messages log records, you can determine whether the machine is restarted without reason or manually. Run the telinit command to instruct init to enter the specified running level. for example, if you restart the system: [SQL] # telinit 6 uses telinit, it will not receive any warning that is as friendly as executing shutdown, this command is less convenient to use for the pending and restarting commands, but to test the modification of the/etc/inittab file. Summary restarting the system is a big task for servers that carry online services. When an operating system fault occurs, we should first consider collecting log information and restart the system if necessary.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.