Ubuntu-18.04 ubuntu14 not like to set as startup scripts by editing rc.local, after the adoption of the following simple settings, it can make rc.local again play a role.
1, edit the file rc-local.service
south you /etc/systemd/system/rc-local.service
2, add the following files in the rc-local.service
[Install]
WantedBy=multi-user.target
Alias=rc-local.service
General boot files need three components
[Unit] section: Start the sequence and dependencies
[Service] section: Starting behavior, how to start a startup type
[Install] section: defines how to install the configuration file, that is how to do boot
3, create a file rc.local, Ubuntu-18.04 is no default /etc/rc.local this file, you need to create your own
south you /etc/rc.local
4, copy the following into the rc.local file
#!/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. sudo echo "在这里行写入你需自启动服务的脚本" > /usr/local/text.log exit 0
5, plus rights to rc.local
sudo chmod +x /etc/rc.local
6. Enable Services
sudo systemctl enable rc-local
7, start the service and check status
sudo systemctl start rc-local.service sudo systemctl status rc-local.service
8, restart and check the file test.log
cat /usr/local/test.log