最近在服务器调程序的时候发现原来的脚本对现在不太适用了,因此换了一种方式来弄。
启动脚本:
#!/bin/bash
#PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
#export PATH
JAVA_HOME=/usr/java/jdk1.7.0_55-cloudera
export PATH=$JAVA_HOME/bin:$PATH
cp="."
for i in $(ls ./lib/*.jar)
do
cp="$cp:$i"
done
cp="$cp:./classes"
echo $cp
JAVA_OPTS=‘-Xms1g -Xmx9g‘
nohup $JAVA_HOME/bin/java $JAVA_OPTS -cp $cp com.XXX.XXXX >> /dev/null 2>&1 &
echo $! > main.pid
停止脚本:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#pid_=$(ps -ef|grep ‘com.XXX.XXXX‘|grep -v ‘grep‘|awk ‘{print $2}‘)
#echo $pid_
#kill -15 $pid_
kill `cat main.pid`
exit 0
时间: 2024-10-08 08:06:57