New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run /etc/rc.d/rc.local as the last Linux bootup task? #27340
Comments
There's no such concept of "last" in systemd, because it makes no sense, it cannot be fulfilled in an event based system, or when more than one such service exists. Add explicit ordering deps instead. Also rc.local is obsolete. Just write a proper service. FInally, this is a bug tracker, not a support forum, as the form should have made abundantly clear... |
Why does systemd still carry it if it doesn't do what it used to do pre-systemd? (I mean rc-local.service) |
Because |
It does something quite similar. But yeah, we should consider killing it now. |
@poettering Lennart, would you accept this kind of change to rc-local.service to keep it in systemd? This way rc.local is ran after crond in both multi-user.target and graphical.target, so at quite late stage before reaching the target:
(I also removed /usr/lib/systemd/system-generators/systemd-rc-local-generator and created a symlink in its place to /dev/null.) |
No, I would not. See mailing list thread: https://lists.freedesktop.org/archives/systemd-devel/2023-April/049038.html |
How about this config? I'm just trying to help keep rc.local alive in systemd. As Mr. Tardon wrote,
|
Why though? This should die, not kept alive "just because". (Why do you mask the generator? That's entirely redundant. The generator will pull in the thing if the script exists, you really don't need to mask it, or move it away or anything like this. It's entirely redundant.) |
I don't know all the logic in systemd for it, but I noticed it puts rc-local.service into /run/systemd for multi-user.target.wants. |
Yes it does. And thus enables it. |
But shouldn't it put it only for the default.target, be it multi-user.target or graphical.target ? |
graphical.target pulls in multi-user.target, hence hooking it into multi-user.target is enough. |
I've already written the one reason why I want to use it. It's simple to run one-off commands and know that every other service is already running. You don't have to figure out the dependencies to other services. Btw, why didn't systemctl enable rc-local.service warn me about the circular dependency problem when I used After=systemd-update-utmp-runlevel.service ? I only noticed it at the next reboot. |
As has already been said, there's no such point in systemd world. Hence, the handling of
Because circular dependencies can only be discovered when a transaction is actually run. |
It is alive and people can use it, with caveats. |
That's not entirely true, there is a org.freedesktop.systemd1.StartupFinished signal, but obviously But there is a way to "do something as soon as startup is finished", using D-Bus. |
AFAICS that covers the startup of PID1, not the system, i.e., it's issued before the default target is even queued.
There isn't, really. Even if this worked as you thought, |
That's completely wrong thing to do. |
I think this works when changing the default target:
|
|
See
That's what I meant by "rc-local service cannot blindly wait for it since it would block itself.", but it can fork et detach something that does the job and immediately Just clarifying here for Google, there is a parallel discussion on the ML anyway. |
systemd version the issue has been seen with
239-68.el8_7.4
Used distribution
Rocky Linux 8.7
Linux kernel version used
6.2.10-100.fc36.x86_64 (host kernel, LXC container)
CPU architectures issue was seen on
x86_64
Component
other
Expected behaviour you didn't see
On Rocky Linux 8.7, the file /etc/rc.d/rc.local contains the following lines:
How to run /etc/rc.d/rc.local as the last Linux bootup task? On Rocky Linux 8.7 it fails to do the task that it
has always served. If it can't be made to run as the last task in Linux bootup, please remove rc-local.service
from systemd to avoid confusion.
Unexpected behaviour you saw
Steps to reproduce the problem
Additional program output to the terminal or log subsystem illustrating the issue
No response
The text was updated successfully, but these errors were encountered: