• 请不要在回答技术问题时复制粘贴 AI 生成的内容
leeger
V2EX  ›  程序员

自己编的脚本有问题, dadiao 帮忙看看~~~(隔壁没法解决)

  •  
  •   leeger · Apr 30, 2017 · 3573 views
    This topic created in 3325 days ago, the information mentioned may be changed or developed.
    本人非专业大拿,从网上看了教程,扒了扒有图比半天时间才写了这段,主要用作:
    自动挂机时实时检测 firefox 状态( eb 有时跳转其他页面,有时 firefox 自动关闭),内存中如果没有 firefox 自动启动!
    但是运行起来有问题,大家帮忙看看!!




    #!/bin/bash
    export DISPLAY=localhost:1.0
    t=0
    XX=30
    while [ 1 ]
    do
    if [ -z $(pgrep firefox) ]
    then
    echo “ firefox is booting now!”
    firefox
    else
    echo “ firefox is working!!!!”
    fi
    sleep 1
    t=$(( $t+1 ))

    if [ $t -gt 10 ]
    then
    killall -9 firefox
    t=0
    fi

    done

    <a href="http://i2.muimg.com/4851/db60c60512d9b0a9.png" title="点击显示原始图片"><img src="http://i2.muimg.com/4851/db60c60512d9b0a9t.jpg"></a>问题:
    1、明明脚本检测时 firefox 已经退出,但是还能检测在运行?(好像第一段 if 失效)
    2、还会出现 Xlib: extension "RANDR" missing on display "localhost:1.0" 错误!,请 dadiao 帮忙看看哪里错了!!!


    谢谢大家了,五一快乐~~~~~
    7 replies    2017-05-01 23:05:15 +08:00
    UnisandK
        1
    UnisandK  
       Apr 30, 2017
    leeger
        2
    leeger  
    OP
       Apr 30, 2017
    是的啊····着急解决啊~~~~
    Vicer
        3
    Vicer  
       May 1, 2017 via Android
    能花钱解决的问题都不是问题
    lulinux
        4
    lulinux  
       May 1, 2017
    @Vicer 有人会说,大家都是兄弟,谈钱伤感情。
    ryanzyy
        5
    ryanzyy  
       May 1, 2017
    不是很懂 bash script 但是
    我只想说
    #!/bin/bash 可以实现的

    #!/bin/python
    #!/bin/ruby 也可以实现
    jyf007
        6
    jyf007  
       May 1, 2017 via Android
    用 systemd 建议改写 init.d 脚本实现,这种估计是把 firefox 改成守护进程使用。
    jyf007
        7
    jyf007  
       May 1, 2017 via Android
    我不会也不用 systemd, 我用 openrc 但是估计有 bug
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1104 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 17:51 · PVG 01:51 · LAX 10:51 · JFK 13:51
    ♥ Do have faith in what you're doing.