Add custom scripts under Linux to boot from boot, standard RPM, example: Set Apache self-boot

Source: Internet
Author: User

Write a script named: autostart.sh, placed in the/etc/init.d/directory, give permission chmod +x/etc/init.d/autostart.sh

The code is as follows

#!/bin/sh#chkconfig:2345 #description: Autostart server Daemon#shell script Body Custom # ..... start ..... stop, ..... ..... ..... restart .... ....

In this case, the service command can be used to see if CHKCONFG can be used

Enter/etc/rc.d/init.d/chkconfig--list autostart//If the service Autostart supports ....---add autostart ')

Perform

Chkconfig autostart onchkconfig--list autostart

Return

Autostart 0:off 1:off 2:on 3:on 4:on 5:on 6:off

You can also turn off

Chkconfig autostart off
The different run level definitions are as follows: # 0-Stop (do not set Initdefault to 0) # 1-Single user mode # s init s = init # 2-multiuser, no nfs# 3-full multiuser mode (standard run level) # 4 -No use for # 5-x11 multi-user graphics mode (xwindow) # 6-reboot (never set the Initdefault to 6)

Then init.6 restart the test

Modify Apache to implement the same self-priming
CD/ETC/INIT.D//Enter this directory CP/USR/LOCAL/APACHE/BIN/APACHECTL.///Copy files to current directory MV Apachectl httpd Find Apachectl, give it a new name Httpdvim httpd//Modify the file, put the following two lines of code head #!/bin/sh below
#chkconfig: 2345 #description: Httpd Server daemon

Service httpd Start

Service httpd STOP: Test if the impact is accessed and then test chkconfig

Chkconfig http on

Chkconfig--list httpd .....

Complete

Add custom scripts under Linux to boot from boot, standard RPM, example: Set Apache self-boot

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.