#!/bin/sh
SERVER_NAME=xxl-job.jar
SERVER_PATH=/usr/local/project/xxl-job/
LOG_PATH=/usr/local/logs/xxl-job/error.log
function status(){
pid=$(ps-ef | grep ${SERVER_NAME}| awk 'NR==1{print $2}');if[[-n "$pid"]];
then
echo"the status of server:$SERVER_NAME is started!";return 1;elseecho"the status of server:$SERVER_NAME is stopped";return 0;
fi;}functionstart(){
status;if["$?" == 1 ];
then
echo"[server:$SERVER_NAME] is starting...";else
nohup java -jar ${SERVER_PATH}${SERVER_NAME} >> ${LOG_PATH} 2>&1 &
echo"[server:$SERVER_NAME] is started success";
fi;};function stop(){
status;if["$?" == 1 ];
then
pid=$(ps-ef | grep ${SERVER_NAME}| awk 'NR==1{print $2}');echo"[server:$SERVER_NAME] is stopping...";kill-9 ${pid}echo"[server:$SERVER_NAME] is stopped";
fi;};
action=$1
case $action in
start)start;;;
stop)
stop;;;
restart)
stop;sleep 1;start;;;
status)
status;;;*)echo"$0 {start|stop|restart|status}"exit 4
;;
esac