解决办法:The unit files have no [Install] section.
Ubuntu 20使用rc-local时,出现这个错误提示。
The unit files have no [Install] section. They are not meant to be enabled using systemctl.
解决办法:
rc-local.service添加Install字段。
[Install]
WantedBy=multi-user.target
结果:
cat /lib/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
[Install]
WantedBy=multi-user.target
重新enable
systemctl enable rc-local.service
创建/etc/rc.local,并赋予执行权限
cat /etc/rc.local
#!/bin/sh
echo "ok" >> ~/rc.local.ok
exit 0
本文链接地址:https://const.net.cn/566.html