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 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, it 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, power-off may lose data or cause file system damage; 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. Send a pending message after executing shutdown-h now: [SQL] <span style = "font-family: Comic Sans MS; font-size: 18px; "> # 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 </span> RUN shutdown-r now and then send the restart message: [SQL] <span style = "font-family: comic Sans MS; font-size: 18px; "> # 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 </span> after shutdown, other users cannot log on to the system, in addition, we can specify the time and description of the system suspension or restart, for example, 1: 00 in the morning for downtime maintenance: [SQL] <span style = "font-family: comic Sans MS; font-size: 18px; "> shutdown-h" going down for scheduled maintenance. expected downtime is 1 hour. "</span> specifies relative shutdown time 15 minutes later shutdown: [SQL] <span style =" font-family: Comic Sans MS; font-size: 18px; "> shutdown-h + 15" going dow N for emergency check. </span> the halt and reboot commands halt record shutdown conditions, terminate unnecessary processes, execute the sync System Call, wait for the file system write operation to complete, 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] <span style = "font-family: Comic Sans MS; font-size: 18px;"> 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] </span> system suspension log: [SQL] <span style = "font-family: Comic Sans MS; font-size: 18px; "> May 3 10:50:22 slot14 shutd Own [11561]: shutting down for system halt May 3 10:50:22 slot14 init: Switching to runlevel: 0 May 3 10:50:22 slot14 user_cmd: 10:50:22 shutdown-h now by root from [root tty1 May 3] </span> by viewing/var/log/messages log records, you can determine whether the machine is restarted without reason or manually. The telinit command executes the telinit command to guide init to the specified running level, such as restarting the system: [SQL] <span style = "font-family: Comic Sans MS; font-size: 18px; "> # telinit 6 </span> when telinit is used, it does not receive any warning that is as friendly as executing shutdown. It is rarely used as a suspension or restart command, however, it is convenient to run the/etc/inittab file modification test. 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.

Related Article

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.