Ubuntu – rc.local

Faced with the fact that in Ubuntu there is no usual CentOS file with me “rc.local“, the solution is the following.

Create a service:

vim /etc/systemd/system/rc-local.service

with the following content:

[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 the file”rc.local” and add it to the execution bit:

touch /etc/rc.local
chmod +x /etc/rc.local

The contents of the file “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

Add service to autorun:

systemctl enable rc-local

run and check the status:

systemctl start rc-local
systemctl status rc-local

Tagged: Tags

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments