Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Linux restart the server

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces Linux how to restart the server, the article is very detailed, has a certain reference value, interested friends must read it!

During the testing process, we inevitably have to restart the testing service. Sometimes the developer is not present, and some companies are restarted by the test itself.

1. Five restart commands of Linux 1. Shutdown

2 、 poweroff

3 、 init

4 、 reboot

5 、 halt

2. Specific description of the five restart commands shutdown

Reboot

Some commonly used shutdown / restart commands under linux are shutdown, halt, reboot, and init, which can restart the system, but the internal working process of each command is different. Through the introduction of this article, I hope you can use various shutdown commands more flexibly.

The 1.shutdown shutdown command shuts down the system safely. Some users will turn off the linux by directly disconnecting the power supply, which is very dangerous. Because linux is different from windows, there are many processes running in the background, so forced shutdown may lead to data loss of processes, make the system in an unstable state, and even damage hardware devices in some systems. Using the shutdown command before the system shuts down, the system administrator will inform all logged-in users that the system is going to shut down. And the login instruction is frozen, meaning that new users can no longer log in. It is possible to shut down the phone directly or delay it for a certain amount of time, and it is also possible to restart it. This is the signal that all processes (process) will receive from the system (signal).

It was decided. This gives programs like vi time to store documents that are currently being edited, while programs like mail and news can leave normally, and so on.

Shutdown performs its job is to send a signal to the init program, asking it to change the runlevel.

Runlevel 0 is used to halt, runlevel 6 is used to reactivate the system, and runlevel 1 is used to put the system into a state where administrative work can be done; this is preset, assuming that there is no-h and no-r parameter to shutdown. To find out what actions are taken during halt or reboot, you can see these runlevels-related materials in this file / etc/inittab.

Shutdown parameter description:

[- t] before changing to another runlevel, tell init how long it will take to shut down.

[- r] restart the calculator.

[- k] doesn't really turn it off, it just sends a warning signal to

Each login (login).

[- h] turn off the power supply (halt) after shutdown.

[- n] instead of init, turn off the phone yourself. The use of this option is discouraged, and the consequences of this option are not always what you expect.

[- c] cancel current process cancels the currently executing shutdown program. So of course there is no time parameter for this option, but you can enter a message for interpretation, and this information will be sent to each user.

[- f] ignore fsck when restarting the calculator (reboot).

[- F] forces fsck when restarting the calculator (reboot).

[- time] sets the time before shutdown (shutdown).

Restart the computer immediately: the simplest shutdown command for shutdown-r now2.halt-- is actually to call shutdown-h for halt. When halt executes, it kills the application process, executes the sync system call, and stops the kernel after the file system write operation is complete.

Parameter description:

[- n] prevents sync system calls, which are used after patching the root partition with fsck to prevent the kernel from overwriting the patched super block with an older version of the superblock.

[- w] is not really rebooting or shutting down, just writing

Wtmp (/ var/log/wtmp) record.

[- d] do not write wtmp records (already included in the option [- n]).

[- f] forced shutdown or restart without calling shutdown.

[- I] turn off all network interfaces before shutting down (or rebooting).

[- p] this option is the default. It is to call poweroff when the computer is turned off.

3.reboot reboot works much like halt, except that it causes the host to restart and halt shuts down. Its parameters are not much different from those of halt.

4.init init is the ancestor of all processes, and its process number is always 1, so sending TERM signals to init terminates all user processes, daemons, and so on. Shutdown uses this mechanism. Init defines eight runlevels (runlevel), with init 0 as shutdown and init 1 as restart. Init can be a long speech, so I won't talk about it here. In addition, there are telinit commands that can change the running level of init. For example, telinit-iS allows the system to enter single-user mode without getting the information and waiting time when using shutdown.

The above is all the contents of the article "how to restart the server in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report