Home  >  Article  >  Operation and Maintenance  >  How to set linux to start automatically at boot

How to set linux to start automatically at boot

青灯夜游
青灯夜游Original
2021-07-26 17:13:2650362browse

How to set up automatic startup on Linux: 1. Add the automatic startup command "/usr/./hello.sh" or "cd /opt && ./hello" in the "/etc/rc.local" file .sh". 2. Add the self-starting script in the "/etc/init.d" directory.

How to set linux to start automatically at boot

#The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.

1. Add the self-starting command to the rc.local file

Execute the command: Edit "/etc/rc.local" and add your The command you want to run at startup

Run the program script: Then add the full path of the program to be executed in the last line of the file.

For example, if you want to execute a hello.sh every time you turn on the computer, and this script is placed under /usr, you can add a line "/usr/./hello." to "/etc/rc.local". sh", or " cd /opt && ./hello.sh "

Note that your command should be added before: exit 0

2. Add a self-starting script in the /etc/init.d directory

linux has many files under "/etc/rc.d/init.d", each file is What you can see is actually some shell scripts or executable binary files
When Linux boots up, it will load and run the programs in the /etc/init.d directory, so we can put the scripts we want to run automatically. Just go to this directory. The startup of system services is achieved in this way.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to set linux to start automatically at boot. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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