Knowledgebase
Table of Contents
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.
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.localEdit the file using the below cat command or through a program like WinSCP.
cat /etc/rc.localAdd 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 0Now create the SystemD service file to register rc.local
sudo nano /etc/systemd/system/rc-local.servicePaste 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.targetReload the system service registry and enable rc-local.
sudo systemctl daemon-reload
sudo systemctl enable rc-localStart and confirm the service is running on the system.
sudo systemctl start rc-localConfirm it's running
sudo systemctl status rc-localIf the service is active the rc.local file will execute content on every server boot.