V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
iZr
V2EX  ›  Linux

Linux下怎么守护进程

  •  
  •   iZr · 2013-11-19 15:11:15 +08:00 · 5489 次点击
    这是一个创建于 3812 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如程序在/root/x

    用 /root/x start

    启动后程序就到 top 里去了,

    然后我我想让这个 x 一直运行 ,死掉了在启动.

    怎么办?

    谢谢
    26 条回复    1970-01-01 08:00:00 +08:00
    roricon
        1
    roricon  
       2013-11-19 15:14:48 +08:00
    supervisor。谁用谁知道。
    roricon
        2
    roricon  
       2013-11-19 15:15:25 +08:00
    http://supervisord.org/
    补个地址……
    iZr
        3
    iZr  
    OP
       2013-11-19 15:15:47 +08:00
    @roricon supervisor 好像只能守护前台的进程吧?比如 ss.但是supervisor守护 nginx 就不行吧
    roricon
        4
    roricon  
       2013-11-19 15:21:52 +08:00
    chilaoqi
        5
    chilaoqi  
       2013-11-19 15:27:22 +08:00
    用 runnit
    timothyye
        6
    timothyye  
       2013-11-19 15:27:50 +08:00
    chilaoqi
        7
    chilaoqi  
       2013-11-19 15:28:16 +08:00
    sandtears
        8
    sandtears  
       2013-11-19 16:09:36 +08:00
    一种可行的办法就是写个crontab排程,定期检测一下
    ms2008
        9
    ms2008  
       2013-11-19 16:12:50 +08:00
    @iZr nginx nodaemon 就可以了
    mozillazg
        10
    mozillazg  
       2013-11-19 16:32:49 +08:00
    最简单的办法就是使用 crontab 定期检测是否存在相关进程,不存在则执行启动命令/脚本

    获取使用 supervisor
    I1l
        11
    I1l  
       2013-11-19 16:43:25 +08:00
    upstart就行了
    LetFoxRun
        12
    LetFoxRun  
       2013-11-19 17:25:45 +08:00 via Android
    crontab
    hui314
        13
    hui314  
       2013-11-19 17:28:44 +08:00
    usoluyun
        14
    usoluyun  
       2013-11-19 18:19:30 +08:00
    supervisor +1
    zjhui
        15
    zjhui  
       2013-11-19 18:31:16 +08:00 via Android
    简单粗暴,whie true死循环一直跑。
    ericls
        16
    ericls  
       2013-11-19 18:37:49 +08:00 via Android
    supervisord 非常好用
    L42y
        17
    L42y  
       2013-11-19 18:39:03 +08:00
    systemd 最高
    wuxqing
        18
    wuxqing  
       2013-11-19 20:31:27 +08:00
    在用monit
    xierch
        19
    xierch  
       2013-11-20 01:04:13 +08:00   ❤️ 1
    debian系的话,upstart 也挺方便的
    http://upstart.ubuntu.com/cookbook/#respawn
    terry
        20
    terry  
       2013-11-20 07:28:05 +08:00
    monit 可以监控自动重启
    PoplarDdd
        21
    PoplarDdd  
       2013-11-20 11:44:43 +08:00
    http://www.qixing318.com/article/use-supervisord-management-process.html
    安装supervisord、配置、示例,希望这篇文章能对你有用
    TankyWoo
        22
    TankyWoo  
       2013-11-20 22:09:05 +08:00
    supervise

    supervisord

    都可以啊,很多类似的强悍工具
    delong
        23
    delong  
       2013-11-21 14:07:41 +08:00
    找个人 守着 :)
    retopara
        24
    retopara  
       2013-11-21 20:29:38 +08:00
    @I1l +1, upstart可以把软件打包成service,以后直接start/stop/restart/status yourapp就行了
    retopara
        25
    retopara  
       2013-11-21 20:30:02 +08:00
    @xierch +1
    retopara
        26
    retopara  
       2013-11-21 20:30:31 +08:00
    @xierch 现在centos也有了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1084 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:25 · PVG 02:25 · LAX 11:25 · JFK 14:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.