#!/bin/bash # # chkconfig: - 98 4 # description: This is test script. . /etc/init.d/functions start(){ touch /var/lock/subsys/testsrv action "start testsrv" } stop(){ rm -f /var/lock/subsys/testsrv action "stopping testsrv" } status(){ [ -f /var/lock/subsys/testsrv ] && echo "testsrv is running" || echo "testsrv is stopped" } restart(){ stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status ;; *) echo "Usage: testsrv {start|stop|status|restart}" ;; esac
chmod +x /etc/init.d/testsrvvim
chkconfig --add testsrvbash
chkconfig --level 123456 testsrv on函數