Shell之定时拉起脚本

来源:互联网 发布:带着淘宝混异界腐书 编辑:程序博客网 时间:2024/06/08 02:13

## 定时拉起脚本scan_shell.sh

#!/bin/sh######################################################################################### Define app execute command here.(please type full name of programs and args)########################################################################################appcmds[0]='/usr/test/app/cmdwifi'appcmds[1]='/usr/test<span style="font-family: Arial, Helvetica, sans-serif;">/app/server_cma_module'</span>appcmds[2]='/usr/test/app/logmodule_server'appcmds[3]='/usr/test/app/bitemodule_server'appcmds[4]='/usr/test/app/proxydb'appcmds[5]='/usr/test/app/server_suu'appcmds[6]='/usr/test/app/seat_control'appcmds[7]='/usr/test/app/relay_module'appcmds[8]='/usr/sbin/named -u named'appcmds[9]='/usr/sbin/dhcpd eth1'appcmds[10]='/opt/lampp/sbin/mysqld'appcmds[11]='/opt/lampp/bin/httpd'appcmds[12]='/usr/donica/app/ku_cma'LOG_FILE='/usr/donica/script/scanproc.log'#sleep 60cd /usr/donica/script/mv scanproc.log scanproc.log.last######################################################################################### Caution: please DO NOT modify the scripts below.#########################################################################################check app command if exist.for cmd in "${appcmds[@]}"; do        filename=$(echo $cmd|awk '{print $1}')        echo ">> Checking sh file: app command - " $cmd  if [ -f "$filename" ]; then        echo ">> SUCCESS~~~~"   else    echo ">> FAILED!!!! please make sure app command exist."    exit  fidonecheckprocess(){  script_name=$(basename $0)  if [ "$1" = "" ];     then       return 1  fi  process_num=$(ps -ef |grep "$1" |grep -v "grep" | grep -v $script_name | wc -l)  return $process_num}########################################################################################Some process need to read config file,we must use correct path######################################################################################cd /usr/donica/app/echo ">> Checking process status..."nums=${#appcmds[*]}while [ 1 ] ; do   for((i=0; i<nums; i++)); do          appcmd=${appcmds[i]}          # get app name from app cmd          appname=${appcmd%% *}          appname=${appname##*/}    $(checkprocess $appname)    check_result=$?    if [ $check_result -eq 0 ]; then        set `date`        printf ">> ["$appname"] DOWN. Trying to start it!"        echo "["$2" "$3" "$4" "$6"] ["$appname"] DOWN. Trying to start it!" >> $LOG_FILE########################################################################################Because of some system services, we should use different start command to start them#######################################################################################    if [ $i -eq 8 ];then        printf "\n"        service named start    elif [ $i -eq 9 ];then        printf "\n"        service dhcpd start


0 0
原创粉丝点击