Ubuntu 16.10/17.10无法通过/etc/rc.local开机启动应用
最新的Ubuntu 16.10/17.10上已经找不到/etc/rc.local这个文件了。但是我们很多配置都是写在这个文件里面的,因此如果直接按照systemd配置服务的话,需要修改很多。这里我们使用一个比较简单的兼容方案。
创建systemd的服务脚本
vim /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
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
激活服务
systemctl enable 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