init.d脚本模板
<pre><code>vim /etc/init.d/chfs
#!/bin/sh
# Prometheus Start Script
# chkconfig: 235 80 70
# description: Starts, stops prometheus
# Debian: update-rc.d chfs defaults
#
### BEGIN INIT INFO
# Provides: Prometheus
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 5
# Default-Stop: 0 1 4 6
# Short-Description: start and stop
# Description: Start, stop
### END INIT INFO
case "$1" in
start)
echo "启动 CHFS"
/usr/bin/chfs --file=/etc/chfs.ini &
;;
stop)
echo "停止 CHFS"
pgrep -f "chfs.ini"|xargs kill -9
;;
restart)
echo "重新启动 CHFS"
pgrep -f "chfs.ini"|xargs kill -9
/usr/bin/chfs --file=/etc/chfs.ini &
;;
*)
echo "Usage: chfs <start|stop|restart>"
;;
esac
exit 0
chmod 755 /etc/init.d/chfs
#Debian
update-rc.d chfs defaults
#CentOs
chkconfig --add chfs
chkconfig --level 2345 chfs on</code></pre>