Production of a self-starting Centos script

Source: Internet
Author: User

One of my Centos boot script Generation 1, switch to/etc/init. d/2, and create sh script vi andy. sh [plain] #! /Bin/sh # add for chkconfig # chkconfig: 2345 70 30 # description: the description of the shell # Brief description of the script # processname: andyStart # Name of the first process, it will be used when setting auto-start later # The following command to start the service/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 indicates the script running level, that is, it can be run in both the 2345 and 234 modes. The mode is a text interface, and the 5 mode is a graphic interface. The mode indicates the sequence number of the script to be started in the future. If the sequence number of other programs is smaller than 70 For example, 44, 45), the script must be started only after these programs are started. 30 indicates the stop sequence number of the script when the system is disabled. Method 1 for executing multiple commands in shell scripts in linux 1. Use each command. Note: The execution of each command will not affect the execution of other commands. In other words, each command is executed, but it is not guaranteed that each command is successfully executed. 2. Separate each command with &. Note: if the preceding command is successfully executed, the subsequent command will be executed. This ensures that the execution process is successful after all commands are executed. 3. Use | to separate each command. Description: | yes or means that the next command is executed only when the previous command fails to be executed until the execution of the previous command is successful. 3. add executable permissions to the script: chmod + x andy. sh 4. Use the chkconfig command to set the script to self-start: chkconfig -- add andy. sh 5. Restart the script and try again!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.