User Tools

Site Tools


rc.local_on_modern_systemd

/etc/rc.local on modern systemd

So the systemd crew thinks that rc.local is bad or something and it's not enabled by default. Put it back by making this file:

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

with content:

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local
 After=remote-fs.target

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target

Note: the "After=remote-fs.target" is something I added so it would wait for NFS. If you don't need NFS to be up, you can remove that line.

Enable this new service:

sudo systemctl enable rc-local

Make a new fresh rc.local:

printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee /etc/rc.local
sudo chmod +x /etc/rc.local

If that doesn't work, the coward's way out is to use the @reboot cron specifier.

Source for the above: this plus this for NFS support.

Launch something in a screen session

If you're looking for my jank-as-hell command that launches something in a screen session on behalf of a user, here it is:

sudo -H -u <USERNAME> screen -dmS <SESSIONNAME> sh -c 'cd <PATH> && ./<SCRIPT_TO_RUN>'
rc.local_on_modern_systemd.txt · Last modified: 2022/03/27 16:17 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki