1-1:重启方法sh脚本1
#!/bin/bash
export app=hdx-monitor.jar
P_ID=`ps -ef|grep -w $app | grep -v "grep" | awk '{print $2}'`
if [ $P_ID ]; then
kill -9 $P_ID
echo "application stop"
fi
echo "application start"
cd /home/hdxapp/manage
nohup java -jar $app &
#tail -f nohup.out
1-2:重启方法sh脚本2
$!为最新打开的pid进程号
#!/bin/sh
echo " =====关闭Java应用======"
PROCESS=`ps -ef |grep java |grep -v grep|grep uav-system-2.0.2.jar|awk '{print $2}'`
for i in $PROCESS
do
echo "Kill the $1 process [ $i ]"
kill -9 $i
done
echo " =====启动Java应用======"
nohup java -Xmx512m -jar uav-system-2.0.2.jar &
echo $! > savePid.txt
cat savePid.txt
rm savePid.txt
tail -f nohup.out
2-1:启动方法sh脚本,指定分配jvm内存大小
#!/bin/sh
echo " =====启动Java应用======"
nohup java -Xmx512m -jar uav-system-2.0.2.jar &
echo $! > savePid.txt
cat savePid.txt
rm savePid.txt
tail -f nohup.out
2-2:启动方法sh脚本,不指定分配jvm内存大小
#!/bin/sh
echo " =====启动Java应用======"
nohup java -jar uav-system-2.0.2.jar &
echo $! > savePid.txt
cat savePid.txt
rm savePid.txt
tail -f nohup.out
3:停止方法sh脚本
#!/bin/sh
echo " =====关闭Java应用======"
PROCESS=`ps -ef |grep java |grep -v grep|grep uav-system-2.0.2.jar|awk '{print $2}'`
for i in $PROCESS
do
echo "Kill the $1 process [ $i ]"
kill -9 $i
done