From time to time, the people want me to the Create LINUX init scripts for them. I usually just take a existing one for another service and the change it up to work for my new application, but the most of them has become so long these days that I end up has to hack out a ton of code just to reduce them down to the very basic s Cript I need. I decided to create this very simple template so I wouldn ' t has to keep trimming down the more complex scripts that one T Ends to find in/etc/init.dThese days.
This waschkconfigcompatible, so call it the name of the your new service and put it in/etc/init.d
Thechkconfig: 235section indicates the default runlevels. For instance, if we called this script/etc/init.d/new-serviceand ranchkconfig new-service on, it would is active in runlevels 2,3 and 5.
The98and55Numbers indicate the order of startup and kill. This means. Using this tag, the startup symbolic Link would is namedS98new-serviceAnd the symbolic link to kill the process would be namedK55new-service.
# # # # SNIP # #
#! /bin/sh# Basic support for IRIX style chkconfig#### chkconfig:235 98 55# description:manages the Services is contro Lling with the Chkconfig command## #case "$" in start) echo-n "Starting New-service" &NB Sp #To run it as root: /path/to/command/to/start/new-service &NB Sp #Or to run it as some other user:  /BIN/SU-USERNAME-C/path/to/command/to/start/new-ser Vice echo "." ;; stop) echo-n "stopping New-service" #To run it as root:   ; /path/to/command/to/stop/new-service #Or to run it as some other user: &nbs P  /BIN/SU-USERNAME-C/path/to/command/to/stop/new-service echo "." ;; *) echo "Usage:/sbin/service new-service {start|stop}" exit 1esacexit 0
This article is from the "Little Bird Your Mother" blog, please make sure to keep this source http://xiaoxiaoniao.blog.51cto.com/8727225/1409567