IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Debian 9/10增加RC.LOCAL文件添加开机启动脚本

    牧人发表于 2023-11-08 11:20:00
    love 0

    Debian 10和Debian 9一样,没有rc.local文件,导致我们有一些脚本无法设置开机启动,查看默认状态:

    systemctl status rc-local
     rc-local.service - /etc/rc.local Compatibility
       Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
      Drop-In: /usr/lib/systemd/system/rc-local.service.d
               └─debian.conf
       Active: inactive (dead)
         Docs: man:systemd-rc-local-generator(8)

    手工创建:

    touch /etc/rc.local

    添加如下内容:

    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    --这里就可以添加要启动的命令了...

    添加执行权限:

    chmod + /etc/rc.local

    加入开机启动:

    systemctl start rc.local
    systemctl enable rc.local


沪ICP备19023445号-2号
友情链接