How To Enable Etc RC - Local With Systemd
How To Enable Etc RC - Local With Systemd
Linux Server
If you are running a Linux distro that uses Systemd, then you may find that your
command in /etc/rc.local file would not run at system boot time. This guide
explains how to enable /etc/rc.local script to run on system startup.
And if you try to enable /etc/rc.local to run on system boot with the command:
As you can see from above, The unit file have no [Install] section. As such
Systemd can not enable it. First we need to create a file:
[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
Save and close the file. To save a file in Nano text editor, press Ctrl+O, then press
Enter to confirm. To exit the file, Press Ctrl+X. Next, run the following command to
make sure /etc/rc.local file is executable.
Output:
Output:
If the above method does not work for you, or you just want some simple commands to
be executed on system boot, then you can also use the @reboot feature in cron to
automatically execute command on system boot. For example, I want my shadowsocks
client to auto start, so I open the root user’s cron file:
sudo crontab -e
And put the following line at the end of it.
In some Linux distributions such as archlinux, the cron daemon is not enabled by
default. So you have to manually enable it. To enable it on archlinux, enter the
following command in the terminal.
Shadowsocks is a socks5 proxy that can be used to bypass Internet firewalls, If you are
interested, click the link below to learn how to setup your own shadowsocks server.
Want to learn more about systemd to efficiently manage your system? Please read the
following tutorial.
How to Use Systemd to Manage Services, Run Levels and Logs on Linux
https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd