crontab配置:
echo "0-59/5 * * * * /software/crontabSpace/PSMonitor.sh >/dev/null 2>&1" >> /var/spool/cron/root
监控脚本:
#!/bin/bash
if [ -f /etc/profile ];
then
. /etc/profile
fi
RUN_CLASS_NAME=("ccrc" "ypdc" "common" "solrIndex" "gczs" "monitorJob" "gczsFirstPage" "ccrcFirstPage" "sender")
LOG_NAME=("ccrc.log" "ypdc.log" "common.log" "solrIndex.log" "gczs.log" "monitorJob.log" "gczsFirstPage.log" "ccrcFirstPage.log" "sender.log")
for i in "${!RUN_CLASS_NAME[@]}"
do
pid=`ps -ef | grep java | grep -E ${RUN_CLASS_NAME[$i]}'$|'${RUN_CLASS_NAME[$i]}' ' | awk '{print $2}'`
if [ "$pid" == "" ];
then
nohup java -jar /software/vbds.jar ${RUN_CLASS_NAME[$i]} >> /software/logs/${LOG_NAME[$i]} 2>&1 &
fi
done