[systemd-devel] rc-local.service and its future in systemd?

Arseny Maslennikov ar at cs.msu.ru
Mon Apr 24 10:33:52 UTC 2023


On Mon, Apr 24, 2023 at 01:20:09PM +0300, Aki Ketolainen wrote:
> > as Lennart already told you in the GitHub issue that "last" just doesn't
> > make sense in systemd, there is also no need to change the dependencies
> > global for everyone. Especially as there are systems out there which
> > doesn't have crond installed (because there are .timer).
> > 
> > Your best bet is really to change all your custom scripts from rc.local
> > into proper .service and instead of crond check out systemd.timer.
> > 
> > BR
> > Silvio
> 
> I tried to set After=systemd-update-utmp-runlevel.service but I got some
> cyclic dependency problem. Would you know how to do that?
> 
> Best regards,
> 
> Aki

If you'd still like to continue using /etc/rc.d/rc.local, and it would be
enough for it to be executed "after boot", IOW, after the default
runlevel at boot is reached, the following four commands might help you:

$ cat >/tmp/order-last.conf <<EOConf
[Unit]
After=default.target

[Service]
StandardOutput=journal+console
StandardError=journal+console
EOConf
$ mkdir -p /etc/systemd/system/rc-local.service.d/
$ mv /tmp/order-last.conf /etc/systemd/system/rc-local.service.d/
$ systemctl daemon-reload

Then, make sure `rc-local.service` is enabled.

default.target should be a symlink to another target, likely multi-user
or graphical.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20230424/4e7c0580/attachment.sig>


More information about the systemd-devel mailing list