解决 Debian 9 /etc/rc.local 开机自启

Debian 9 默认不带 /etc/rc.local 文件,而 rc.local 服务却还是自带的:

/lib/systemd/system/rc.local.service

为了解决这个问题,我们需要手动创建一个 /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.

exit 0

然后赋予权限:

chmod +x /etc/rc.local

再把开机自启的命令加在 exit 0 前面,然后重启验证是否生效。

添加新评论