Weblutions Documentation
Weblutions Main Site Contact Us Our Discord
Some pages are still pending proper formatting, if required refer to the legacy documentation website.
Knowledgebase IconKnowledgebase

Weblutions Documentation / Knowledgebase / How to enable rc.local on Ubuntu

Updated

How to enable rc.local on Ubuntu

By Josh M. 1 mins 4

Table of Contents

Introduction

rc.local is a powerful tool on Ubuntu which can assist in automating applications booting up automatically on server boot. While technically still supported on Ubuntu it's disabled by default and considered deprecated by some. However, it works on all current LTS Ubuntu versions.


This guide will go through the process of activating and enabling the rc.local service on a Ubuntu server to allow any commands to execute after the server boots. In this example, we'll start faxstore automatically.


How to Enable

1. Create the /etc/rc.local file

By using the touch and cat command we can create and ensure the system has execute permissions on the rc.local file.

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

2. Add a Start-up Command & Exit Statement

Edit the file using the below cat command or through a program like WinSCP.

cat /etc/rc.local

Add the below content for FaxStore, or any other commands to run on startup.

#!/bin/bash
# Add any startup commands below this line

screen -dmS faxstore bash -c "cd /home/faxstore; node .; exec bash"

exit 0

3. Create the System Service

Now create the SystemD service file to register rc.local

sudo nano /etc/systemd/system/rc-local.service

Paste the following content

[Unit]
Description=Compatibility for /etc/rc.local
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

4. Reload SystemD & Enable the Service

Reload the system service registry and enable rc-local.

sudo systemctl daemon-reload
sudo systemctl enable rc-local

5. Start the Service

Start and confirm the service is running on the system.

sudo systemctl start rc-local

Confirm it's running

sudo systemctl status rc-local

If the service is active the rc.local file will execute content on every server boot.