使用service启动服务,并且设置开机启动

来自:互联网
时间:2018-08-25
阅读:

编写脚本jdms

chmod 777 jdms

#! /bin/bash
#chkconfig: 35 85 15
#description: this is jdmsdeamon.
start() {
        echo "start jdmsdeamon: "
        /usr/local/jdms/bin/jdmsdeamon
        echo "start success"
}
 
stop() {
        echo "stop jdmsdeamon: "
        killall jdmsdeamon
        echo "stop jdms_umdeamon: "
        killall jdms_umdeamon
        echo "stop jdms_imdeamon: "
        killall jdms_imdeamon
        echo "stop success"
}
 
restart() {
        stop
        start
        echo "restart success"
}
 
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                restart
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart}"
                exit 2
esac

保存后:chmod 777 jdms

然后:cp jdms /etc/init.d/

现在你可以使用service jdms start

然后: chkconfig –add jdms

现在是开机启动了,可以重启看看是否运行了

返回顶部
顶部