V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
leeger
V2EX  ›  程序员

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

  •  
  •   leeger · 2017-04-30 13:14:01 +08:00 · 2860 次点击
    这是一个创建于 2551 天前的主题,其中的信息可能已经有所发展或是发生改变。
    本人非专业大拿,从网上看了教程,扒了扒有图比半天时间才写了这段,主要用作:
    自动挂机时实时检测 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 条回复    2017-05-01 23:05:15 +08:00
    UnisandK
        1
    UnisandK  
       2017-04-30 13:27:54 +08:00
    leeger
        2
    leeger  
    OP
       2017-04-30 13:34:31 +08:00
    是的啊····着急解决啊~~~~
    Vicer
        3
    Vicer  
       2017-05-01 00:40:01 +08:00 via Android
    能花钱解决的问题都不是问题
    lulinux
        4
    lulinux  
       2017-05-01 05:28:08 +08:00
    @Vicer 有人会说,大家都是兄弟,谈钱伤感情。
    ryanzyy
        5
    ryanzyy  
       2017-05-01 11:13:54 +08:00
    不是很懂 bash script 但是
    我只想说
    #!/bin/bash 可以实现的

    #!/bin/python
    #!/bin/ruby 也可以实现
    jyf007
        6
    jyf007  
       2017-05-01 23:04:28 +08:00 via Android
    用 systemd 建议改写 init.d 脚本实现,这种估计是把 firefox 改成守护进程使用。
    jyf007
        7
    jyf007  
       2017-05-01 23:05:15 +08:00 via Android
    我不会也不用 systemd, 我用 openrc 但是估计有 bug
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4062 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 05:13 · PVG 13:13 · LAX 22:13 · JFK 01:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.