Shell判断子进程(pid)状态实现动态循环
来源:互联网 发布:淘宝店铺哪里买 编辑:程序博客网 时间:2024/06/15 08:12
[root@zhangwan2 xingcheng]# cat get_data_1.sh.20171101 #!/bin/bash#Date:2017/7/29#Author: create by xingcheng#Mail:#Function:抓取微信后台数据状态监控,二次判断执行脚本。##################################################################################加载环境变量source /etc/profile#设置系统语言#export LANG="en_US.UTF-8"##################################################################################定义变量DIR=/web/wechatbi/processtime1=$(date +%s)#################################################################################cd $DIRchown -R php-fpm /web/wechatbi/public/qrcodechown -R php-fpm /web/wechatbi/logs##################################################################################查看进程Semih(){sleep 180count=$(ps aux|grep 'php /web/wechatbi/tasks/cli.php thread index'|grep -v "grep" |wc -l) if [ $count -eq 0 ] then get_started Judgement_time else Judgement_time fi}##################################################################################拉起子脚本get_data_2(){for I in $(seq 1 100)do { /bin/bash /home/xingcheng/xingcheng/get_data_2.sh }& sleep 2done}##################################################################################判断次数轮训次数Judgement_time(){local time2=$(date +%s)if [ $(($time2-$time1)) -ge 9000 ]then kill -9 $(ps aux|grep 'php /web/wechatbi/tasks/cli.php thread index'|awk '{print $2}') exitelse Semihfi}##################################################################################清理数据库get_started(){php /web/wechatbi/tasks/cli.php recover recover >/web/wechatbi/logs/get_data.log 2>/web/wechatbi/logs/get_data.errget_data_2}#################################################################################get_startedSemih
二、子脚本
[root@zhangwan2 xingcheng]# cat get_data_2.sh #!/bin/bash#Date:2017/7/29#Author: create by xingcheng#Mail:#Function:抓取微信后台数据状态监控,二次判断执行脚本。source /etc/profileDIR=/web/wechatbi/processcd $DIRfrequency=1function judge(){ php /web/wechatbi/tasks/cli.php thread index $(cat $pid_2) >/web/wechatbi/logs/get_data.log 2>/web/wechatbi/logs/get_data.err local status_2=$(echo $?) frequency=$(($frequency+1)) if [ $status_2 -ne 0 -a $status_2 -ne 137 ] then if [ $frequency -eq 5 ] then /usr/bin/python /home/xingcheng/monitor/mail/mail.py "99999999@qq.com" "Error(): error in zhuashuju" "$1" exit else sleep 10 judge $(cat $pid_2) fi fi}php /web/wechatbi/tasks/cli.php thread index >/web/wechatbi/logs/get_data.log 2>/web/wechatbi/logs/get_data.errstatus_1=$(echo $?)pid_1=$(echo $$)pid_2=$(($pid_1+1))if [ $status_1 -ne 0 -a -f $pid_2 ] then judge $(cat $pid_2)fi
阅读全文
0 0
- Shell判断子进程(pid)状态实现动态循环
- shell脚本循环判断进程是否存在
- linux c 父进程判断子进程退出状态
- [shell]判断一个字符串是否为数字字符串的两种方法(是否为进程号(PID))
- linux shell 检查进程PID
- linux命令(26):Bash Shell 获取进程 PID
- shell通过端口号获取PID(进程号)
- shell 变量 判断 循环
- shell 循环判断语法
- shell运算、判断、循环
- shell--赋值,判断,循环
- cat /proc/$PID/status进程状态
- 查看进程状态/proc/pid/stat
- 查看进程状态/proc/pid/stat
- 通过 /proc/[pid]/ 查看进程状态
- shell子进程解析
- shell子进程
- bash shell获取进程的pid
- springboot源码分析1-springboot版本号获取
- java web和Android第一次交互(登录)
- UML常用图--类图,用例图,序列图(时序图),协作图(通信图),状态图,活动图
- Jetty插件,运行web应用配置
- 分享给好友功能的实现
- Shell判断子进程(pid)状态实现动态循环
- strlen与sizeof
- python 求8位各不相同的整数,1357位之和等于2468位之和,且为完全平方数
- 关于大型网站技术演进的思考(十二)--网站静态化处理—缓存(4)
- 配置服务器支持https访问
- 使用API网关构建微服务
- android CPU架构异常
- 项目:通讯录(C语言的实现)
- 都在做SEO原创?文章编辑更加注重质量