Debian9 解决 rc.local 问题

技术教程 风为裳 5浏览 0评论 繁體

Debian 9 (Stretch)预设不使用 rc.local, 所以会找不到/etc/rc.local 。
但是还是有办法可以使用rc.local

添加rc-local.service

cat > /etc/systemd/system/rc-local.service <<EOF
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
EOF

新建rc-local文件

cat > /etc/rc.local <<EOF
#!/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
EOF

添加权限

chmod +x /etc/rc.local

启动

systemctl enable rc-local
systemctl start rc-local.service

查看状态,出现active为启动成功。

[email protected]:~# systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset:
enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (exited) since Fri 2018-08-24 03:53:50 EDT; 4s ago

 

转载请注明:风为裳 » Debian9 解决 rc.local 问题

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址