16.03.2018 10:19, aleivag пиÑ?еÑ?: >> >> >> Won't work. Status changes only when job for a unit completes and jobs >> are executed in order of dependencies. Actually, jobs are *queued* in >> order of dependencies so nothing would indicate that you are going to >> shutdown until it is too late (i.e. all normal services are stopped). >> >> > yes, but those units have started, so during a `systemctl reboot` you can > execute > > [~] systemctl list-jobs shutdown.target reboot.target > JOB UNIT TYPE STATE > 1972 reboot.target start waiting > 1974 shutdown.target start waiting > > 2 jobs listed. > > and get if shutdown has started > Yes, you are right. I'm sure I have seen cases when jobs were not present in other cases so I assumed it will be here as well. > the other thing that may help you know if you are in shutdown mode is > execute `systemctl is-system-running` and then check if returns `stopping`, > during a shutdown is suppose to return something like that. and i think it > does this by checking is shutdown.target has started ( > https://github.com/systemd/systemd/blob/7a30dfeb18d09940a844389e06b25ca2bca5e093/src/core/manager.c#L3833-L3836 > ) > Yes, could be more reliable. > > Logically runlevel is not changed until *after* new runlevel has been >> reached. Practically systemd does not update runlevel during shutdown at >> all. > > > yeap, you are right here, i was wrong :D >