-2

I created a systemd service rc-local.service as below and placed it in /etc/systemd/system, enabled it, started it. It is supposed to run the /etc/rc.local script at boot time, which it does. I know this because to writes to the log file /var/log/rc-local.log (which is freshly created every time the /etc/rc.local script is run) without error messages. The only trouble is, the deamons that are supposed to be installed at boot time by rc.local are not installed. If I run rc.local as root after login everything runs as it should.

Here's the service file.

[Unit]
Description=Run a boot-time shell script
After=network.target
StartLimitBurst=5
StartLimitIntervalSec=10

[Service]
Type=simple
Restart=on-failure
RestartSec=2
User=root
ExecStart=/etc/rc.local

[Install]
WantedBy=multi-user.target

What can I change to make it all work?

14
  • If /etc/rc.local exists and is executable, systemd automatically creates and enables a unit for running it. Would the script running twice in parallel because of your extra unit cause problems?
    – muru
    Commented Jul 4 at 1:35
  • This web page is not letting me post the 3000-odd line script. Commented Jul 4 at 2:07
  • 1
    We don't want to see a 3000-line script either. Reduce your rc.local to a minimal part which reproduces the behaviour (writes to log file every time, but doesn't run some other specific action at boot)
    – muru
    Commented Jul 4 at 2:20
  • 1
    There is no Ubuntu 20.03. If you're talking about 20.04, systemd-rc-local-generator is indeed present and installed by default. Please edit your question and use code blocks to add code.
    – muru
    Commented Jul 4 at 2:49
  • 1
    1. Edit your question: askubuntu.com/posts/1519502/edit to see how I added code formatting. 2. See: askubuntu.com/editing-help#code
    – muru
    Commented Jul 4 at 3:00

1 Answer 1

0

I stopped my custom rc-local.service, moved it to a TEMP folder, restarted all the daemons, rebooted the system. New log file was created showing outputs that indicate all my daemons have been started, iptables configuration loaded. Checks with ps ax corroborated my daemons running. Checking now on iptables but it all looks good. Thank you @muru.

1
  • Nice to know things worked fine with the defaults!
    – muru
    Commented Jul 4 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .