If you do not want systemd, consider Devuan.
As I said about CentOS 7 and about Debian 8 and about Ubuntu 15:
You're using a systemd+Linux operating system.
/etc/rc.local
is a double backwards compatibility mechanism in systemd, because it is a backwards compatibility mechanism for a mechanism that was itself a compatibility mechanism in the van Smoorenburg System 5rc
clone.Using
/etc/rc.local
can go horribly wrong. People have been surprised by the fact that systemd doesn't runrc.local
in quite the same way, in quite the same place in the bootstrap, as they are used to. (Or erroneously expect: It did not, in fact, run last in the old system, as the OpenBSD manual still points out.) Others have been surprised by the fact that what they set up inrc.local
expecting the old ways of doing things, is then completely undone by the likes of newudev
rules, NetworkManager,systemd-logind
,systemd-resolved
, or various "Kit"s.As exemplified by "https://unix.stackexchange.com/questions/389289/", some operating systems already provide systemd without the backwards compatibility features such as the
systemd-rc-local-generator
generator. Whilst Debian still retains the backwards compatibility features, Arch Linux builds systemd with them turned off. So on Arch and operating systems like it expect/etc/rc.local
to be entirely ignored.Forget about
rc.local
. It's not the way to go. You have a systemd+Linux operating system. So make a proper systemd service unit, and don't begin from a point that is two levels of backwards compatibility away. (On Ubuntu and Fedora, it is three times removed, the van Smoorenburg System 5rc
clone that followedrc.local
having then been itself twice superseded, over a decade ago, first by upstart and then by systemd.)Also remember the first rule for migrating to systemd.
This is not even a new idea that is specific to systemd. On van Smoorenburg
rc
and Upstart systems, the thing to do was to make a proper van Smoorenburgrc
script or Upstart job file rather than userc.local
. Even FreeBSD's manual notes that nowadays one creates a proper Mewburnrc
script instead of using/etc/rc.local
. Mewburnrc
was introduced by NetBSD 1.5 in 2000.
/etc/rc.local
dates from the time of Seventh Edition Unix and before. It was superseded by/etc/inittab
and a runlevel-basedrc
in AT&T Unix System 3 (with a slightly different/etc/inittab
in AT&T Unix System 5) in 1983. Even that is now history.Create proper native service definitions for your service management system, whether that be a service bundle for the nosh toolset's
service-manager
andsystem-control
, an/etc/rc.d/
script for Mewburnrc
, a service unit file for systemd, a job file for Upstart, a service directory for runit/s6/daemontools-encore, or even an/etc/init.d/
script for van Smoorenburgrc
.In systemd, such administrator-added service unit files go in
/etc/systemd/system/
usually (or/usr/local/lib/systemd/system/
rarely). With the nosh service manager,/var/local/sv/
is a conventional place for local service bundles. Mewburnrc
on FreeBSD uses/usr/local/etc/rc.d/
. Packaged service unit files and service bundles, if you are making them, go in different places, though.
- Lennart Poettering et al. (2014). systemd-rc-local-generator. systemd manual pages. Freedesktop.org.
rc.local
. FreeBSD System Manager's Manual. 2016-04-23.- https://unix.stackexchange.com/a/233581/5132
- Lennart Poettering (2011-08-29). Plese remove
/etc/rc.local
orchmod -x
it. Redhat bug #734268.- https://unix.stackexchange.com/a/211927/5132
- Dirk Schmitt (2017-12-19).
rc.local
is starting to early. systemd bug #7703- https://wiki.archlinux.org/index.php?title=Systemd&diff=378926&oldid=378924
- Benjamin Cane (2011-12-30). When it's Ok and Not Ok to use
rc.local
. bencane.com.- https://unix.stackexchange.com/a/49636/5132
- Lennart Poettering (2010-10-01). How Do I Convert A SysV Init Script Into A systemd Service File?. 0pointer.de.
- https://askubuntu.com/questions/523369/
- Jonathan de Boyne Pollard (2015).
/etc/inittab
is a thing of the past.. Frequently Given Answers.- Jonathan de Boyne Pollard (2014). A side-by-side look at run scripts and service units.. Frequently Given Answers.
- Jonathan de Boyne Pollard (2014). A real-world worked example of setting up and running a service with nosh. Softwares.
- Jonathan de Boyne Pollard (2016). "Missing system search paths from the
systemd.unit
manual page". Errata for systemd doco. Frequently Given Answers.
-JdeBP answered Sep 27, 2018 at 16:06, Stephen Kitt edited Jan 19 at 9:26 CC BY-SA 4.0
This workaround is not for Devuan 4 Chimaera (based on Debian 11 Bullseye). It has a device called /etc/systemd/system/rc.local.service to emulate rc.local from a systemd perspective but does not have systemd.
- See the Devuan Chimaera 4.0 stable release announcement.
A workaround is at Home / Sysadmin / rc.local deprecated by mox.
- Make a systemd script to emulate rc.local (change "Wants" and "After" depending on what your script does! This one was modified to require networking which is probably good enough for most people.):
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/rc.local
[Install]
WantedBy=multi-user.target
[Unit]
Wants=bluetooth.service
After=bluetooth.service
- Enable it:
systemctl enable local-starttasks.service