forked from guchengwuyue/yshopmall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjar-run2.sh
64 lines (59 loc) · 1.59 KB
/
jar-run2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#cription: 启动重启server服务
#端口号,根据此端口号确定PID
PORT=767
#启动命令所在目录
HOME='/home/sszn/task-agc'
#查询出监听了test.jar端口TCP协议的程序
pid=$(ps -ef | grep gdw-agc-task-1.0.0.0.jar | grep -v grep | awk '{print $2}')
start(){
echo "start running cloud-core ............... "
if [ -n "$pid" ]; then
echo "server already start,pid:$pid"
echo "pid:$pid agc-job port:$PORT 服务已经在运行了,请停止后再 执行 sh run.sh start "
return 0
fi
#进入命令所在目录
cd $HOME
# 启动服务控制台日志输出到nohup.out文件中
nohup java -jar gdw-agc-task-1.0.0.0.jar >> /home/sszn/task-agc/log/agc-$(date +%Y-%m-%d).log 2>&1 &
echo "running success agc-job port:$PORT"
echo "agc-job port:$PORT 服务启动成功 ..... "
}
stop(){
echo "stopping running cloud-core ............... "
if [ -z "$pid" ]; then
echo "not find program on port:$PORT"
echo "agc-job port:$PORT 服务已经被关闭了请执行 sh run.sh start "
return 0
fi
#结束程序,使用讯号2,如果不行可以尝试讯号9强制结束
kill -9 $pid
rm -rf $pid
echo "kill program use signal 2,pid:$pid"
}
status(){
if [ -z "$pid" ]; then
echo "not find program on port:$PORT"
else
echo "program is running,pid:$pid"
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
$0 stop
sleep 2
$0 start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|status}"
exit 0
esac