[systemd-devel] best way to monitor begining of runlevel
Lennart Poettering
lennart at poettering.net
Tue Apr 19 17:24:31 PDT 2011
On Sat, 02.04.11 01:11, Vasiliy G Tolstov (v.tolstov at selfip.ru) wrote:
> Hello. I have a daemon, that runs before init system, it do some things
> and must sleep before system go to 3 or 5 runlevel.
> That is the best way to waiting ? I'm not only using systemd, but other
> init systems too...
> Very simple method - in cycle parse /var/log/wtmp (/var/log/wtmpx) and
> get current runlevel, but does it exists more elegant way to do whis?
systemd still maintains wtmp with something resembling a runlevel. Note
however that systemd actually doesnt know runlevels really, and just
emulates them.
If you care for a solution that woirks everywhere, and you want to
monitor this, use inotify on wtmp. If you do not care for other init
systems use D-Bus to subscribe to systemd PropertyChange events on the
targets you are interested in.
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list