Ubuntu18.04生成rc.local
Ubuntu没有自带其他linux版本自带的rc.local文件的开机自启动方法,所以要自己生成rc.local文件:
- 生成rc-local.service文件将一下内容复制进rc-local…service文件
sudo gedit /etc/systemd/system/rc-local.service
将一下内容复制进该文件
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local #脚本文件位置
[Service]
Type=forking
ExecStart=/etc/rc.local start #配置的脚本文件rc.local为start
TimeoutSec=0
StandardOutput=tty #标准输出
RemainAfterExit=yes
SysVStartPriority=99 #优先级,当有多个开机启动文件时可以设置不同的值
[Install]
WantedBy=multi-user.target
- 生成rc.local
sudo gedit /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 ena