Linux Resin开机自动启动脚本写法

Linux   Resin开机自动启动脚本写法

#!/bin/sh
#chkconfig:345 99 10
#description:auto start resin
#/etc/init.d/resin.sh
export export JAVA_HOME=/usr/weaver/jdk1.8.0_151
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
export  RESIN_PATH=/usr/weaver/Resin4
 
RETVAL=0
start_resin=$RESIN_PATH/bin/startresin.sh
stop_resin=$RESIN_PATH/bin/stopresin.sh
start()
{
        if [ -f $start_resin ];
        then
                echo $"Starting Resin"
                ${start_resin}
                echo "OK"
                return $RETVAL
        fi
}
stop()
{
        if [ -f $stop_resin ];
        then
                echo $"Stopping Resin"
                ${stop_resin}
                sleep 1
                echo "OK"
                return $RETVAL
        fi
}
 
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
restart)
        echo $"Restarting Resin"
        $0 stop
        sleep 10
        $0 start
        ;;
*)
echo $"Usage:$0{start|stop|restart}"
esac
exit 0

注意:(下面这几个参数需要根据自己的实际路径进行填写)

export export JAVA_HOME=/usr/weaver/jdk1.8.0_151
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
 
RETVAL=0
RESIN_PATH=/usr/weaver/Resin4/bin/startresin.sh

2、创建完启动脚本后,需要对脚本进行授权

#chmod u+x resin

#chkconfig --add resin

#service resin start 启动

#service resin stop 关闭

你可能感兴趣的:(服务器,linux,运维)