How to RedHat Linux init script
时间:2006-06-30 来源:pianoch
1. RedHat Linux use chkconfig command to configure init script.
#chkconfig --list list all of initscript services. #chkconfig <service-name> on #chkconfig <service-name> off <service-name>: the script name on /etc/init.d These two command does not start/stop service actuallly, these just tell the system, these service will be started/stoped on next system reboot.2. Use service command start/stop service manually
service <service-name> start service <service-name> stop3. Difference with ordinary system V init script
See the example below, pay attension to #chkconfig: 35 90 12 let chkconfig know: 35: run level 90: start priority 12: stop priority lock file is necessary. #!/bin/bash#
# chkconfig: 35 90 12
# description: My server
#
#Source function library.
. /etc/init.d/functions
start() {
initlog -c "echo -n Starting my server: "
/path/to/servicename &
### touch the lock file ###
touch /var/lock/subsys/servicename
success $"My server startup"
echo
}
stop() {
initlog -c "echo -n Stopping my server: "
killproc servicename
### Remove the lock file ###
rm -f /var/lock/subsys/servicename
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status servicename
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
相关阅读 更多 +