Shell之定时拉起脚本
2015-11-30 18:02
609 查看
## 定时拉起脚本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 60 cd /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 fi done checkprocess() { 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
相关文章推荐
- 一组Linux Shell Scripting小练习
- 监控服务器端口,Down掉会自动重启,并发送邮件 Linux Shell
- linux Shell之cut命令用法
- win linux命令行下写webshell语句
- 让Linux下的cron以秒为单位执行shell脚本的3种方法
- shell知识点01
- Shell基础学习
- ShellSort
- shell 脚本
- powershell启用脚本
- SHELL编程入门(二)---SHELL循环与条件
- 本地代码调用远程shell代码
- shell命令中if语句的后街分号作用
- 如何确保 Shell 脚本只有一个实例运行
- shell 参数
- shell 参数
- shell 引号 转义符 通配符 特殊字符
- 利用Powershell快速导出域控所有用户Hash
- linux关于bashrc与profile的区别
- shell脚本中的$*,$@和$#