Re: rc-local.service and its future in systemd?

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

 



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.


Did you test this yourself? I couldn't get it to work. If I don't disable systemd-rc-local-generator, it'll create a multi-user.target.wants for rc-local.service in /run/systemd. rc-local.service is also referenced in multiple other service files in /usr/lib/systemd/system.

I arrived into this following config that is now working:

1)

# /etc/systemd/system/rc-local.service.d/override.conf
[Unit]
After=systemd-user-sessions.service

[Install]
WantedBy=default.target

2)

mkdir /root/systemd
mv /usr/lib/systemd/system-generators/systemd-rc-local-generator /root/systemd/ ln -s /dev/null /usr/lib/systemd/system-generators/systemd-rc-local-generator

3)

chmod 700 /etc/rc.d/rc.local
systemctl enable rc-local.service

As one Red Hat employee once said: "And I'm pretty sure that the people who still insist on using it would shout at us very loudly if rc-local.service were removed...".

I hope rc-local.service can be kept in systemd in the future.

Best regards,

Aki

P.S. My hunch was correct and rc.local is now (After=systemd-user-sessions.service) ran after crond.

root 1045 0.0 0.0 3272 1792 ? Ss 19:58 0:00 /usr/sbin/atd -f root 1046 0.0 0.0 224304 3584 ? Ss 19:58 0:00 /usr/sbin/crond -n root 1047 0.0 0.0 222940 3328 ? Ss 19:58 0:00 /bin/bash /etc/rc.d/rc.local start root 1049 0.0 0.0 224692 3328 ? R 19:58 0:00 \_ ps auxwwf root 1050 0.0 0.0 238216 3200 ? S 19:58 0:00 \_ sort -n -k 2,2

cat /etc/rc.d/rc.local

#!/bin/bash

date > /var/tmp/boot.ps
ps auxwwf | sort -n -k 2,2 >> /var/tmp/boot.ps



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux