linux 启动java

#!/bin/sh echo "Current DIR is " $PWD # ignore signal hup int quit tstp trap "" 1 2 3 24 start_server() { ulimit -c unlimited # export LD_LIBRARY_PATH=`pwd`/deps/capn/libs:$LD_LIBRARY_PATH # rm -f *.pid # nohup $PWD/comet-server ./icomet.conf & nohup java -jar lf-lfchat.jar >> ist.log & } kill_server() { #ps -aux | grep comet-server | grep -v grep | awk {'print $2'} | xargs kill -2 ps -aux | grep java | grep -v grep | awk {'print $2'} | xargs kill -2 } while [ 1 ] do #propserverpid=`ps -ef | grep comet-server | grep -v grep |awk '{print $2}'` propserverpid=`ps -ef | grep java | grep -v grep |awk '{print $2}'` # ${now}${propserverpid} >> pid.log if [ ! "$propserverpid" ] then echo "propserver is down, now starting ..." start_server fi sleep 1 done #kill_server

 

#!/bin/sh
echo "Current DIR is " $PWD

# ignore signal hup int quit tstp
trap "" 1 2 3 24

 start_server() {
        ulimit -c unlimited
#       export LD_LIBRARY_PATH=`pwd`/deps/capn/libs:$LD_LIBRARY_PATH
#       rm -f *.pid
#       nohup $PWD/comet-server ./icomet.conf &
        nohup java -jar lf-lfchat.jar >> ist.log &
}

 kill_server() {
        #ps -aux | grep comet-server | grep -v grep | awk {'print $2'} | xargs kill -2
        ps -aux | grep java | grep -v grep | awk {'print $2'} | xargs kill -2
}

while [ 1 ]
do
        #propserverpid=`ps -ef | grep comet-server | grep -v grep |awk '{print $2}'`
        propserverpid=`ps -ef | grep java | grep -v grep |awk '{print $2}'`

#       ${now}${propserverpid} >> pid.log
        if [ ! "$propserverpid" ]
        then
                echo "propserver is down, now starting ..."
                start_server
        fi
        sleep 1
done

#kill_server

 

root@iZ2893a7a8cZ:/opt/ist# cat restart.sh 
#cp ist.log ist.log${now}
#mv ist.log ist.log.${date}
#killall -9 java
pid=$(cat java.pid )
kill -15 $pid
#pgrep java
java -jar LF_S_SignalProc.jar >> ist.log & echo $! > java.pid
#tail -f ist.log
root@iZ2893a7a8cZ:/opt/ist# cat _shutdownmoni.sh 
pidstat |grep moni_ist.sh| awk  '{print $4}'|xargs kill -9
root@iZ2893a7a8cZ:/opt/ist# cat shutdown.sh 
#pidstat |grep moni_ist.sh| awk  '{print $4}'|xargs kill -9
pid=$(cat java.pid )
kill -15 $pid
#killall java
#pgrep java|xargs >> javaid
pidstat |grep moni_ist.sh| awk  '{print $4}'|xagrs cat>>ist.log
tail -f ist.log

root@iZ2893a7a8cZ:/opt/ist# cat start.sh 
java -jar LF_S_SignalProc.jar  -Dfile.encoding=UTF-8  >> ist.log & echo $! > java.pid
root@iZ2893a7a8cZ:/opt/ist# cat moni_ist.sh
#
echo "Current DIR is " $PWD

# ignore signal hup int quit tstp
trap "" 1 2 3 24

 start_server() {
        ulimit -c unlimited
        nohup java -jar LF_S_SignalProc.jar  -Dfile.encoding=UTF-8 >> ist.log &
#-Dfile.encoding java -jar -Dfile.encoding=UTF-8 LF_S_SignalProc.jar >> ist.log=UTF-8
}


 kill_server() {
        ps -aux | grep java | grep -v grep | awk {'print $2'} | xargs kill -2
}

while [ 1 ]
do
        propserverpid=`ps -ef | grep java | grep -v grep |awk '{print $2}'`

        ${now}${propserverpid} >> pid.log
        if [ ! "$propserverpid" ]
        then
                echo "propserver is down, now starting ..."
                start_server
        fi
        sleep 1
done
root@iZ2893a7a8cZ:/opt/ist# 

 

你可能感兴趣的:(linux)