linux jexus服务设置开机启动
本文为大家分享jexus服务设置开机启动的具体代码,供大家参考,具体内容如下
linux的服务开机设置一般在/etc/init.d/里
而jexus的默认安装目录在/usr/jexus里启动文件为jws参数有startstoprestart
这里贡献一个刚写好的jexus的开启启动脚本
#!/bin/bash ###BEGININITINFO # #Provides:jws #Required-Start:$local_fs$remote_fs #Required-Stop:$local_fs$remote_fs #Default-Start:2345 #Default-Stop:016 #Short-Description:jws #Description:Thisfileshouldbeusedtoconstructscriptstobeplacedin/etc/init.d. # ###ENDINITINFO ##Fillinnameofprogramhere. PROG="jws" PROG_PATH="/usr/jexus"##Notneed,butsometimeshelpful(if$PROGresidesin/optforexample). PROG_ARGS="start" PID_PATH="/var/run/" start(){ if[-e"$PID_PATH/$PROG.pid"];then ##Programisrunning,exitwitherror. echo"Error!$PROGiscurrentlyrunning!"1>&2 exit1 else ##Changefrom/dev/nulltosomethinglike/var/log/$PROGifyouwanttosaveoutput. $PROG_PATH/$PROG$PROG_ARGS2>&1>/var/log/$PROG& $pid=`psax|grep-i'jws'|sed's/^\([0-9]\{1,\}\).*/\1/g'|head-n1` echo"$PROGstarted" echo$pid>"$PID_PATH/$PROG.pid" fi } stop(){ echo"beginstop" if[-e"$PID_PATH/$PROG.pid"];then ##Programisrunning,sostopit pid=`psax|grep-i'jws'|sed's/^\([0-9]\{1,\}\).*/\1/g'|head-n1` kill$pid rm-f"$PID_PATH/$PROG.pid" echo"$PROGstopped" else ##Programisnotrunning,exitwitherror. echo"Error!$PROGnotstarted!"1>&2 exit1 fi } ##Checktoseeifwearerunningasrootfirst. ##Foundathttp://www.cyberciti.biz/tips/shell-root-user-check-script.html if["$(id-u)"!="0"];then echo"Thisscriptmustberunasroot"1>&2 exit1 fi case"$1"in start) start exit0 ;; stop) stop exit0 ;; restart) stop start exit0 ;; **) echo"Usage:$0{start|stop|restart}"1>&2 exit1 ;; esac
最后记得sudochmod+x/etc/init.d/jws
添加自动启动服务sudoupdate-rc.djwsdefaults
删除自动启动服务sudoupdate-rc.djwsremove
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。