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

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


相关博文:

发表新评论