Ubuntu 18.04 : how to run start up script
- Create a service:
12sudo vi /etc/systemd/system/rc-local.service - Add your code there:
123456789101112131415[Unit]Description=/etc/rc.local CompatibilityConditionPathExists=/etc/rc.local[Service]Type=forkingExecStart=/etc/rc.local startTimeoutSec=0StandardOutput=ttyRemainAfterExit=yesSysVStartPriority=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
123456789101112131415#!/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:
12sudo systemctl enable rc-local - Start service and check status:
123sudo systemctl start rc-local.servicesudo systemctl status rc-local.service - If all goes well you can add your
code
to the/etc/rc.local
file then restart it.
Leave a Reply