zoukankan      html  css  js  c++  java
  • UBUNTU 添加开机启动程序

    1.在/etc/init.d/目录下新建脚本文件“jr”

    
    

    注:脚本文件jr的内容格式,有严格规定。例程如下:


    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          binfmt-support
    # Required-Start:    $local_fs $remote_fs
    # Required-Stop:     $local_fs $remote_fs
    # Default-Start:     S 1 2 3 4 5 6 
    # Default-Stop:
    # Short-Description: Support for extra binary formats
    # Description:       Enable support for extra binary formats using the Linux
    #                    kernel's binfmt_misc facility.
    ### END INIT INFO
    
    
    echo "xx" >> /jr/jr.txt
    exit 0





    2.命令:#sudo update-rc.d jr defaults 98

    //设置运行的优先级为98

    //运行结果如下:


    wu@ubuntu:~$ sudo update-rc.d jr defaults 98
    update-rc.d: warning: jr start runlevel arguments (2 3 4 5) do not match LSB Default-Start values (S 1 2 3 4 5 6)
    update-rc.d: warning: jr stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (none)
     Adding system startup for /etc/init.d/jr ...
       /etc/rc0.d/K98jr -> ../init.d/jr
       /etc/rc1.d/K98jr -> ../init.d/jr
       /etc/rc6.d/K98jr -> ../init.d/jr
       /etc/rc2.d/S98jr -> ../init.d/jr
       /etc/rc3.d/S98jr -> ../init.d/jr
       /etc/rc4.d/S98jr -> ../init.d/jr
       /etc/rc5.d/S98jr -> ../init.d/jr
    
    //表示已经在/etc/rcX.d/的相应目录下,创建启动脚本成功。


    3.为了验证一下,可以运行#sysv-rc-conf

    找到相应名称的脚本,看启动标志打开了没有。

    4.放心地重启吧,看看效果。





  • 相关阅读:
    C++ 重载运算符简单举例
    Python 的几种推导式
    Linux 系统目录结构
    Shell 文件包含
    Shell 文件测试运算符
    Shell 函数定义与调用
    Shell 数组定义与获取
    C 语言精髓之变参函数
    Vim 字符串替换命令
    S5PV210 串口实验(中断方式)
  • 原文地址:https://www.cnblogs.com/techstone/p/2661244.html
Copyright © 2011-2022 走看看