linux自启动脚本.sh
while [ 1 ]; do
PRO_NUM=`ps -ef | grep "cms$" | grep -v "grep" | wc -l`
if [ $PRO_NUM -eq 1 ]; then
sleep 60
else
killall -9 cms
cd /usr/local/x'x
exec /usr/local/xx &
sleep 60
fi
done
#! /bin/sh
#当前脚本所在目录
ROOTDIR=$(cd `dirname $0`; pwd)
cd $ROOTDIR
export LD_LIBRARY_PATH=$ROOTDIR
echo $LD_LIBRARY_PATH
datename=$(date +%Y-%m-%d_%H-%M-%S)
echo $datename
dirname=1startlog
mkdir -p $dirname
while [ 1 ]; do
PRO_NUM=`netstat -nlp | grep :9000 | awk '{print $7}' | awk -F"/" '{ print $1 }' | wc -l`
if [ $PRO_NUM -eq 1 ]; then
sleep 30
else
nohup $ROOTDIR/xxServer -platform Minimal > ./$dirname/$datename.log 2>&1 &
sleep 30
fi
done
disown