-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathauto_kill_recover.sh
61 lines (40 loc) · 1.01 KB
/
auto_kill_recover.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
#!/bin/bash
date
path=$1
pid=$(ps aux | grep java | grep $path | grep -v grep | awk '{print $2}')
echo "pid $pid"
if [ -n "$pid" ]; then
echo "正在杀死进程,PID: $pid"
kill -9 "$pid"
echo "已杀死进程,PID: $pid"
else
echo "未找到匹配的进程,无需杀死"
exit 1
fi
kill -9 $pid
echo "kill $pid $path"
echo "开始休眠..."
current_datetime=$(date +"%Y-%m-%d %H:%M:%S")
echo $current_datetime
sleep 10
current_datetime=$(date +"%Y-%m-%d %H:%M:%S")
echo $current_datetime
echo "结束休眠.,,."
current=$(date +%s)
# 检查系统类型
if [ "$os_type" == "Linux" ]; then
echo "This is Linux."
cd /root/ems
elif [ "$os_type" == "Darwin" ]; then
echo "This is macOS."
cd ~/ty60/ems
else
echo "This is " $os_type
cd /root/ems
fi
current=$(date +%s)
echo $current-application.log
java -jar $path > $current-application.log 2>&1 &
echo "启动完毕....." $path $current-application.log
current_datetime=$(date +"%Y-%m-%d %H:%M:%S")
echo $current_datetime