zoukankan      html  css  js  c++  java
  • Centos7 安装系统服务、开机自启动

     

    Centos7 安装系统服务

    1 编写可执行程序

    * 这里可以是任意编程语言(C、C++、Java、PHP、Python、Perl ...)编写的程序;

    当前假设此程序的执行目录为:

     /myservice/bin

    2 编写服务脚本

    #! /bin/bash
    
    # chkconfig: 2345 80 90
    # description: this is your auto run program.
    
    start() {
    echo "starting service ..."
    cd /myservice/bin
    ./start.sh
    echo "ok"
    }
    
    stop() {
    echo "stop service ..."
    cd /myservice/bin
    ./stop.sh
    echo "ok"
    }
    
    case "$1" in
    "start")
    start
    ;;
    "stop")
    stop
    ;;
    "restart")
    stop
    start
    ;;
    *)
    
    echo $"Usage: $0 {start|stop|restart}"
    exit 0
    esac

    请注意检查脚本的前面,是否有完整的两行

    #chkconfig: 2345 80 90
    #description: this is your auto run program.

    3 添加到服务 & 开机启动项

    chkconfig --add myservice
    chkconfig --level 2345 myservice on

     4 chkconfig 参考命令

    chkconfig --list [name]
    chkconfig --add name
    chkconfig --del name
    chkconfig [--level levels] name <on|off|reset>
    chkconfig [--level levels] name
  • 相关阅读:
    struts 提交问题
    struts spring整合出错
    hibernate.cfg.xml
    myeclipse copy问题
    myeclipse copy时出的问题
    mysql sql 语句
    Spring_Hibernate
    WebView
    Notification
    Handler(消息机制)
  • 原文地址:https://www.cnblogs.com/bruceleeliya/p/10740563.html
Copyright © 2011-2022 走看看