服务器宕机等场景下拉起或者定期重启进程等,可用本文的脚本处理。 其中start.sh为拉起脚本,restart.sh为重启脚本。 无 process_name=jbossbin_path=/ICA20/jboss-4.3.1.GA-9000/bin #!/bin/bashdate. /etc/profile. ~/.bash_profilepath=$(cd `dirname $0`;
服务器宕机等场景下拉起或者定期重启进程等,可用本文的脚本处理。
其中start.sh为拉起脚本,restart.sh为重启脚本。
process_name=jboss
bin_path=/ICA20/jboss-4.3.1.GA-9000/bin
#!/bin/bash
date
. /etc/profile
. ~/.bash_profile
path=$(cd `dirname $0`; pwd)
source $path/start.ini
#check whether the process is exist
is_alive=0
echo "Check process [$process_name]..."
cmd=`ps -ef | grep java | grep -c $process_name`
if test $cmd -ge 1; then
echo "Process [$process_name] exist..."
is_alive=1
else
echo "Process [$process_name] not exist..."
is_alive=0
fi
if [[ "$is_alive" -eq 0 ]];then
echo "Start [$process_name]..."
echo "cd $bin_path..."
cd $bin_path
nohup sh run.sh &
fi
echo "Check finished."
process_name=TTSserver
bin_path=/ICA20/ttsClient
#!/bin/bash
date
. /etc/profile
. ~/.bash_profile
path=$(cd `dirname $0`; pwd)
source $path/restart.ini
#check whether the process is exist
is_alive=0
echo "Check process [$process_name]..."
cmd=`ps -ef | grep 20 | grep -c $process_name`
if test $cmd -ge 1; then
echo "Process [$process_name] exist..."
is_alive=1
else
echo "Process [$process_name] not exist..."
is_alive=0
fi
if [[ "$is_alive" -eq 1 ]];then
echo "Kill [$process_name]..."
kill -9 $(ps -ef|grep $process_name|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ')
sleep 60s
fi
echo "cd $bin_path..."
echo "Start [$process_name]..."
cd $bin_path
nohup ./$process_name -n 20 &
echo "Check finished."