# linux jar 启动脚本
#!/bin/bash
app='cs_video-0.0.1-SNAPSHOT.jar'
jdk='/opt/tools/jdk1.8.0_102/bin/java'
args=''
cmd=$1
pid=`ps -ef|grep java|grep $app|awk '{print $2}'`
startup(){
nohup $jdk -jar $args $app &
tail -f nohup.out
}
if [ ! $cmd ]; then
echo "Please specify args 'start|restart|stop'"
exit
fi
if [ $cmd == 'start' ]; then
if [ ! $pid ]; then
startup
else
echo "$app is running! pid=$pid"
fi
fi
if [ $cmd == 'restart' ]; then
if [ $pid ]
then
echo "$pid will be killed after 3 seconds!"
sleep 3
kill -9 $pid
fi
startup
fi
if [ $cmd == 'stop' ]; then
if [ $pid ]; then
echo "$pid will be killed after 3 seconds!"
sleep 3
kill -9 $pid
fi
echo "$app is stopped"
fi
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
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
#!/bin/bash
jdk='/data/product/ncsp/tools/jdk1.8.0_171/bin/java'
app='cs_zeus_cms-0.0.1-SNAPSHOT.jar'
debug='-Xdebug -Xrunjdwp:transport=dt_socket,address=9003,server=y,suspend=n '
agent='-javaagent:/data/product/ncsp/agent/skywalking-agent.jar -Dskywalking.agent.namespace=cs_micro_sp -Dskywalking.agent.service_name=sp_oms -Dskywalking.collector.backend_service=192.168.220.126:11800'
args='-Dfile.encoding=UTF-8 -Xms1024m -Xmx1536m -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=512M'
nacos='debug='-Xdebug -Xrunjdwp:transport=dt_socket,address=9003,server=y,suspend=n ''
cmd=$1
pid=`ps -ef|grep java|grep $app|awk '{print $2}'`
pid=`ps -ef|cat application.pid|grep -v 'grep \|tail'|awk '{print $1}'`
sudo nohup $jdk $debug $agent $args -jar $app $nacos & > ./nohup.log
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11