Home > php教程 > PHP开发 > How to shutdown and restart commands in linux

How to shutdown and restart commands in linux

高洛峰
Release: 2016-12-17 16:51:23
Original
1837 people have browsed it

Shutdown command:

1. Halt Shut down immediately
2. Poweroff Shut down immediately
3. Shutdown -h now Shut down immediately (for root users)
4. Shutdown -h 10 Automatically shut down after 10 minutes
If it is set through the shutdown command If shutting down, you can use the shutdown -c command to cancel the restart

Restart command:

1, reboot
2, shutdown -r now Restart immediately (for root user)
3, shutdown -r 10 Automatically restart after 10 minutes (root user) Use)
4. shutdown -r 20:35 Restart when the time is 20:35 (for root users)
If the restart is set through the shutdown command, you can use the shutdown -c command to cancel the restart

shutdown parameter description:
 
[-t] Before changing to other runlevels? Tell init how long to shut down after.
 
 [-r] Restart the calculator.
 
 [-k] Doesn’t really shut down? It just sends a warning signal to each login [login].
 
 [-h] Turn off the power after shutdown [halt].
 
 [-n] Don’t use init? Instead, shut down the computer yourself. Not encouraged to use this option? And the consequences of this option are often not always what you expect

.
 
 [-c] cancel current process Cancel the shutdown process currently being executed. So of course this option has no time parameter, but you can enter a message to explain it, and this message will be sent to each user.

 

 [-f] Ignore fsck when restarting the calculator [reboot].
 
 [-F] Force fsck when restarting the calculator [reboot].
 
  [-time] Set the time before shutdown [shutdown]

halt----the simplest shutdown command


[-n] Prevent sync system call? It is used after patching the root partition with fsck? Prevents the kernel from overwriting the patched

superblock with an older version of the superblock.

 

 [-w] Isn’t it a real reboot or shutdown? It just writes wtmp [/var/log/wtmp] records.
 
 [-d] Do not write wtmp records [included in option [-n]].
 
 [-f] Force shutdown or restart without calling shutdown.
 
 [-i] Before shutting down (or restarting)? Turn off all network interfaces.
 
 [-p] This option is the default option. Just call poweroff when shutting down.
 
 3.reboot
 
 The working process of reboot is almost the same as halt. But it causes the host to restart, while halt is to shut down. Its parameters are similar to halt.

If you want to shut down directly after pressing it instead of using the default restart method, you only need to edit the /etc/inittab file. In this file, there will be the following


line:

  # Trap CTRL-ALT-DELETE
  
  ca::ctrlaltdel:/sbin/shutdown -t3 -r now
Copy after login

You can - The r option is changed to -h, and the modified command is as follows:

  # Trap CTRL-ALT-DELETE
  
  ca::ctrlaltdel:/sbin/shutdown -t3 -h now
Copy after login

When modifying the file, register as root. Behavioral comment lines starting with "#" describe the script file and are not processed by the computer.

Comment statement. The root user can also use the shutdown command to shut down. The shtudown command can be executed locally or remotely. When the system is locked

and the keyboard cannot be used, the shutdown command can be executed through remote registration

[ Kill unavailable processes] or execute the command /sbin/shutdown -rn now

  

  The shutdown command skips some standard and very time-consuming shutdown steps. This command runs faster. This command is used when a problem occurs in the system.


This is useful when answering questions (the option -n causes the system to kill all processes before restarting).
  
Please pay attention to the above command usage process. For security reasons, it is not possible to register directly as root (for example, using telnet ) to the remote host. You can only register as a normal user, and then use the su command to turn yourself into a super user. The shutdown command can also shut down the host after a period of time. For example, execute the following command as root :
 
 $ /sbin/shutdown -r 23:59
 
  will cause the host to restart at 23:59. If the shutdown seems too long for you, you can use the following two commands: reboot and halt. Their functions

can, as its name suggests, restart the computer and shut down respectively.
 

Another interesting shutdown method is to switch the system to run level 0 (shutdown) or run level 6 (restart).

 
 For example The following command will shut down the system.
  

  $ init 0

  
 For different run level definitions, please refer to the file /etc/inittab. net!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template