One of my CentOS boot-up scripts made
First, switch to/etc/init.d/
Second, make SH script vi andy.sh
[Plain]
#!/bin/sh
#add for Chkconfig
#chkconfig: 2345 70 30
#description: The description of the shell #关于脚本的简短描述
#processname: Andystart #第一个进程名, the rear settings will be used when the boot
#下面要启动服务的命令
/etc/init.d/mysqld start;
/ETC/INIT.D/HTTPD start;
/sbin/iptables-i input-p TCP--dport 80-j ACCEPT;
Service Iptables Save;
Service iptables Restart;
Description
2345 refers to the running level of the script, that is, in 2345 of the 4 modes can be run, 234 are text interface, 5 is the graphical interface x
70 refers to the future startup sequence number of the script, if the start sequence number of other programs is smaller than 70 (such as 44, 45), the script needs to wait until these programs are started before starting.
30 refers to the stop order number of the script when the system shuts down.
How a shell script executes multiple commands under Linux
1. Separate each command;
Note: The execution of each command will not affect the execution of other commands. In other words, each command executes, but does not guarantee that each command will execute successfully.
2. Separate && between each command
Note: If the previous command executes successfully, the following command will be executed. This ensures that after all commands have been executed, the execution process is successful.
3. Between each command with | | Separated
Description: | | It means that only the preceding command fails to execute the next command until a successful command is executed.
Third, add executable permissions to the script: chmod +x andy.sh
Iv. using the Chkconfig command to set the script to self-start: chkconfig--add andy.sh
Five, restart a try it!
Creation of the CentOS boot-up script