GameDatabaseService/bin/processor_check.sh

26 lines
790 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# crontab里加上进程自动拉起任务做个简单的监控
# */1 * * * * source /etc/profile;sh /apprun/${YOUR_APP_NAME}/bin/processor_check.sh
# processor_check.sh脚本内容如下
APP_NAME=dispose_platform.jar
WORK_PATH=$(cd `dirname $0`; pwd)
pids=`ps -ef | grep $APP_NAME | grep -v grep | wc -l`
if [ "$pids" -le 0 ]
then
echo "start $APP_NAME processor ......"
cd $WORK_PATH
cd ..
nohup sh bin/start.sh >/dev/null 2>&1 &
sleep 5
pids=`ps -ef | grep $APP_NAME | grep -v grep | wc -l`
if [ "$pids" -gt 0 ]
then
echo "$APP_NAME processor started"
else
echo "Failed to start $APP_NAME processor"
fi
else
echo "$APP_NAME processor is running ......"
fi