Add rc.local Service for Ubuntu 18.04

Modify /lib/systemd/system/rc-local.service

Append some content:

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

Configure /etc/rc.local

1
2
touch /etc/rc.local
chmod 755 /etc/rc.local

Edit /etc/rc.local, and the content is as follows:

1
2
#!/bin/bash
echo "test rc " > /var/test.log

Reboot your OS, and check /var/test.log.

0%