0%

Ubuntu 18.04开机启动项设置

之前写过14.04的启动配置,16.04后ubuntu启动配置方式改变了。

创建文件rc-local.service

1
2
sudo vi /etc/systemd/system/rc-local.service

输入内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[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

创建文件rc.local

1
2
sudo vi /etc/rc.local

输入内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/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.

/root/.pyenv/shims/supervisord -c /root/serverSpace/supervisor/supervisor.conf

exit 0

给执行权限

1
2
sudo chmod +x /etc/rc.local

启动服务

1
2
sudo systemctl enable rc-local
sudo systemctl start rc-local.service

重启设备看下吧