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
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
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