zoukankan      html  css  js  c++  java
  • ubuntu 开机启动shell脚本

    1.创建shell启动脚本test

    2.将启动脚本复制到 /etc/init.d 目录下

    3.设置脚本文件权限

    sudo chmod 755 /etc/init.d/test

    4.设置脚本启动

    sudo update-rc.d test defaults 95   //95 为启动优先级,越小优先级越高

    // 执行后输出信息

    update-rc.d: warning: /etc/init.d/test missing LSB information
    update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
    Adding system startup for /etc/init.d/test ...
    /etc/rc0.d/K95test -> ../init.d/test
    /etc/rc1.d/K95test -> ../init.d/test
    /etc/rc6.d/K95test -> ../init.d/test
    /etc/rc2.d/S95test -> ../init.d/test
    /etc/rc3.d/S95test -> ../init.d/test
    /etc/rc4.d/S95test -> ../init.d/test
    /etc/rc5.d/S95test -> ../init.d/test
    4.卸载启动脚本

    sudo update-rc.d -f test remove

    // 执行后输出信息

    Removing any system startup links for /etc/init.d/test ...
    /etc/rc0.d/K95test
    /etc/rc1.d/K95test
    /etc/rc2.d/S95test
    /etc/rc3.d/S95test
    /etc/rc4.d/S95test
    /etc/rc5.d/S95test
    /etc/rc6.d/K95test

    其实解决办法就是在#!/bin/bash下面添加:

    ### BEGIN INIT INFO
    # Provides:          bbzhh.com
    # Required-Start:    $local_fs $network
    # Required-Stop:     $local_fs
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: tomcat service
    # Description:       tomcat service daemon
    ### END INIT INFO

    当然,也可以一劳永逸的:

    apt-get remove insserv
  • 相关阅读:
    Attributes in C#
    asp.net C# 时间格式大全
    UVA 10518 How Many Calls?
    UVA 10303 How Many Trees?
    UVA 991 Safe Salutations
    UVA 10862 Connect the Cable Wires
    UVA 10417 Gift Exchanging
    UVA 10229 Modular Fibonacci
    UVA 10079 Pizza Cutting
    UVA 10334 Ray Through Glasses
  • 原文地址:https://www.cnblogs.com/ExMan/p/10845383.html
Copyright © 2011-2022 走看看