【问题标题】:shell script to monitor php process用于监控 php 进程的 shell 脚本
【发布时间】:2015-05-26 11:43:31
【问题描述】:

如何在进程死亡时自动重启?

我目前正在这样做:

#!/bin/bash
while true;do
    ps -aux 2>/dev/null |grep redis_subscribe|grep -v grep >/dev/null
    if [ $? -ne 0 ];then
        php /data/www/wwwroot/app.eclicks.cn/oil/index.php public/redis_subscribe subscribe   2>&1 >>/data/cilogs/manitor/image_upload.log &
    fi;
    sleep 10;
done;

【问题讨论】:

  • 死了是什么意思?
  • 这里不是很清楚你的意思。试着给出更多关于你想要什么、你的代码应该做什么以及为什么它没有用的解释。

标签: php shell process


【解决方案1】:
#!/bin/bash
while true;do
    ps -aux 2>/dev/null |grep redis_subscribe|grep -v grep >/dev/null
    if [ $? -ne 0 ];then
        php /data/www/wwwroot/app.eclicks.cn/oil/index.php public/redis_subscribe subscribe   2>&1 >>/data/cilogs/manitor/image_upload.log &
    fi;
    sleep 10;
done;

2>/dev/null 是将“警告:语法错误,可能是假的”重定向到 /dev/null

并且,>/dev/null 是相同的。 希望能帮到你!

【讨论】:

    猜你喜欢
    • 2011-11-04
    • 2015-08-27
    • 1970-01-01
    • 2015-12-21
    • 1970-01-01
    • 2016-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多