zoukankan      html  css  js  c++  java
  • Linux 进程退出后自动启动

    /**********************************************************************
     *                    Linux 进程退出后自动启动
     * 说明:
     *     在系统中,我们有时候会希望后台程序能够一直运行,即使程序出错了,
     * 也是希望程序能够自动启动,并继续运行。
     *
     *                                  2016-12-10 深圳 南山平山村 曾剑锋
     *********************************************************************/
    
    一、参考文档:
        How to automatically restart a linux background process if it fails?
            http://superuser.com/questions/507576/how-to-automatically-restart-a-linux-background-process-if-it-fails
    
    二、解决办法:
        1. 如参考文档中的说明,分三种情况:
            1. BusyBox init:在/etc/inittab中添加:
                ::respawn:/bin/myprocess
            2. Linux "System V" init:在/etc/inittab中添加:
                myprocess:2345:respawn:/bin/myprocess
            3. systemd:
                1. 在/etc/systemd/system/myprocess.service中添加:
                    [Unit]
                    Description=My Process
    
                    [Service]
                    ExecStart=/bin/myprocess
                    Restart=always
    
                    [Install]
                    WantedBy=multi-user.target
                2. systemctl enable myprocess.service
        2. 详情请参考:
            http://buildroot.uclibc.org/downloads/manual/manual.html#_init_system
                3. systemctl start myprocess.service
  • 相关阅读:
    MySQL的事务用法:
    MySQL基本命令(增删改查,check约束)总结:
    (转)nodejs npm国内镜像
    NodeJS学习笔记(三)
    NodeJS学习笔记(二).js
    minimist的用法
    npm link没有效果的问题
    DOM Based XSS介绍
    NodeJS学习笔记(一)
    用Ruby写自动生成Sql语句脚本遇到的问题
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/6156213.html
Copyright © 2011-2022 走看看