ubuntu18.04 不再使用initd管理系统,改用systemd
- 设置启动参数
vim /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
Alias=rc-local.service
- 添加软链接
ln -s /lib/systemd/system/rc.local.service /etc/systemd/system/rc.local.service
- 创建服务
touch /etc/rc.local
- 赋可执行权限
chmod 755 /etc/rc.local
- 编辑自启动服务
vim /etc/rc.local
#开机打印hello
echo "hello" > /etc/test.log
# 开机启动zookeeper
/usr/local/zookeeper/bin start
网友评论