Centos boot script

Source: Internet
Author: User

Centos boot script
1) create a STARTUP script under/etc/init. d and set it as an executable file (chmod + x)

#!/bin/bash# chkconfig: - 85 15# description:  Gold Web Server.# Source function library.. /etc/rc.d/init.d/functionshomedir=/home/jack/goldweb/binprog=goldwebpidfile=/var/run/goldweb.pidstart() {     echo -n $"Starting $prog: "     cd $homedir     ./goldweb &}stop() {
Echo-n $ "Stopping $ prog:" killproc-p $ {pidfile}
} Case "$1" in start) start; stop) stop; status) status-p $ {pidfile}; restart) stop start ;;*) echo $ "Usage: $ prog {start | stop | restart | status}"; esac Note: The following two annotations must be added; otherwise, the chkconfig cannot be added.
# chkconfig: - 85 15# description:  Gold Web Server.
 
Chkconfig is followed by the running level, startup priority, and shutdown priority.
 

# The default running level. RHS uses the following levels:

0: Shutdown

1: single-user mode

2: multi-user mode without network support

3: multi-user mode with network support

4: reserved, not used

5. Multi-user mode with network support and X-Window support

6. reboot the system.

Detailed explanation of each running level:

0 indicates that the machine is shut down.

1 is the single-user mode, just like the security mode in Win9x.

2: multi-user mode, but not supported by NFS.

3 is a complete multi-user mode, which is a standard operation level.

4. Generally, you can use it to do things in some special cases. For example, you can switch to this mode to make some settings when the battery of your laptop is exhausted.

5 is X11, And it enters the X Window System.

6. Restart the init 6 server.

 
2) use chkconfig to add boot start 
 
  • Create a service
 chkconfig --add newservice
  • Check whether the creation is successful
chkconfig --list newservicenewservice      0:off   1:off   2:off   3:on    4:on    5:on    6:off
 
  • Enable startup
Chkconfig newservice on
 
  • Other chkconfig operations
Chkconfig -- del newservice // delete a service
Chkconfig newservice off // disable startup
Service newservice status // query service status
Service newservice stop // stop the service
Service newservice start // start the service

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.