Set the script to self-starting under Linux system

  
 

Sometimes we need to set up a script in the server to let it start itself when it boots. The method is as follows: cd /etc/init.dvi youshell.sh #Change yourshell.sh to your own script name and write your own script and save and exit. When writing the script, please add the following comment #add for chkconfig#chkconfig: 2345 70 30#description: the description of the shell #About the short description of the script#processname: servicename #first process name, set after the start It will be used when the description: 2345 refers to the running level of the script, that is, it can be run in 4 modes of 2345, 234 is the text interface, 5 is the graphical interface X70 refers to the future startup sequence number of the script, if other The startup sequence number of the program is smaller than 70 (such as 44, 45), then the script needs to wait for these programs to start before starting. 30 is the stop sequence number of the script when the system is shut down. It should be noted that the code is designed to call the environment variable, which needs to be specified in the script in advance, because the /etc/profile file is not loaded when the system is started. The script adds a source /etc/profile before the call to add executable permissions to the script: chmod +x youshell.sh uses the chkconfig command to set the script to start chkconfig --add servicename so your script can be booted It runs automatically.

Copyright © Windows knowledge All Rights Reserved