zoukankan      html  css  js  c++  java
  • linux脚本遇到的一点问题

    系统环境:

    # uname -r
    2.6.32-431.el6.x86_64
    # cat /etc/redhat-release
    CentOS release 6.5 (Final)

    对服务器状态监控的一段脚本中使用了查询进程信息的几句代码:

    server="srs"
    care_pid=`pgrep -f $server`
    #echo "$server pid =" $care_pid
    care_ps=`ps aux | grep $server | grep -v "grep"`
    #echo $care_ps

    直接命令行执行脚本,输入信息如下:

    srs pid = 5939
    root 5939 1.4 0.0 51648 22288 ? S Jun22 1209:38 ./objs/srs -c ./conf/srs.conf

    设置定时器crontab 自动执行脚本,输出信息如下::

    srs pid = 5939 24244 24245
    root 5939 1.4 0.0 51648 22288 ? S Jun22 1209:38 ./objs/srs -c ./conf/srs.conf 
    root 24244 1.0 0.0 106060 1284 ? Ss 14:35 0:00 /bin/sh -c /usr/local/srs/video_server_monitor.sh >> /usr/local/srs/monitor.log 
    root 24245 0.0 0.0 106060 936 ? S 14:35 0:00 /bin/sh -c /usr/local/srs/video_server_monitor.sh >> /usr/local/srs/monitor.log 
    root 24252 0.0 0.0 106060 512 ? S 14:35 0:00 /bin/sh -c /usr/local/srs/video_server_monitor.sh >> /usr/local/srs/monitor.log

    目前尚不知道什么缘故,暂时更改脚本解决了问题。具体的原因还需要下次查询。
    换个写法定时执行得到正确结果,更改如下:

    server="srs"
    care_pid=`pgrep -n $server`
    #echo "$server pid =" $care_pid
    care_ps=`ps p $care_pid u`
    #echo $care_ps
  • 相关阅读:
    Netty 超时机制及心跳程序实现
    ZJUTACM
    寻找素数对
    HDU 1021 Fibonacci Again
    HDU 1019 Least Common Multiple
    HDU 1017 A Mathematical Curiosity
    HDU 1014 Uniform Generator
    HDU 1013 Digital Roots
    HDU 1008 Elevator
    Educational Codeforces Round 2 B. Queries about less or equal elements
  • 原文地址:https://www.cnblogs.com/zzugyl/p/9494054.html
Copyright © 2011-2022 走看看