title: Ubuntu-18-开机自启
date: 2018-07-01 16:01:33
categories:
- Linux
- Linux
tags: [linux,linux]
ubuntu18.04 不再使用initd管理系统,改用systemd
- 设置启动参数
vim /lib/systemd/system/rc.local.service
[Unit]Description=/etc/rc.local CompatibilityDocumentation=man:systemd-rc-local-generator(8)ConditionFileIsExecutable=/etc/rc.localAfter=network.target[Service]Type=forkingExecStart=/etc/rc.local startTimeoutSec=0RemainAfterExit=yesGuessMainPID=no#这一段原文件没有,需要自己添加[Install]WantedBy=multi-user.targetAlias=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
