Re: doing something before everything else

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Jul 22, 2017, at 8:28 AM, Andrew Holway <andrew.holway@xxxxxxxxx> wrote:
> I want to run a script before systemd starts doing stuff but I cant find
> anything online about how that could happen. It seems /etc/rc.local is
> depreciated now?

You can’t run anything before systemd starts, since it is started by the kernel before the local filesystems have been mounted.

/etc/rc.d/rc.local still runs, but it is a systemd service run as rc-local.service, contingent on /etc/rc.d/rc.local existing and being executable.

Now, if you want to run something before systemd starts other services, you need to create your own systemd unit, and set up dependencies such that the service starts before those services.  For example, you’d put "Before=network-pre.target” in the [Unit] section if you wanted your service to start before the network was brought up.  For what it’s worth, rc-local.service has a dependency that actually starts it *after* the network service comes up, so it starts later in the startup anyway.


--
Jonathan Billings <billings@xxxxxxxxxx>


_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux