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:

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

with the following content:

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

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

The contents of the file "rc.local":

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/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:

1
systemctl enable rc-local

run and check the status:

1
2
systemctl start rc-local
systemctl status rc-local

Tagged: Tags

Subscribe
Notify of
guest


0 Comments
Inline Feedbacks
View all comments