- Create a service:
sudo vi /etc/systemd/system/rc-local.service
- Add your code there:
[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
- Create and make sure
/etc/rc.local
is executable and add this code inside it:
sudo chmod +x /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 enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0
- Enable the service:
sudo systemctl enable rc-local
- Start service and check status:
sudo systemctl start rc-local.service sudo systemctl status rc-local.service
- If all goes well you can add your
code
to the/etc/rc.local
file then restart it.
2018-11-07