How can I predict systemd's shutdown order?

Is there a way to get systemd to tell me the rough order in which it will shutdown services when I cleanly shut the whole system down? Since systemd will shut things down in parallel, I appreciate there is no way to know the exact order, but it would still be very helpful to know what constraints systemd will impose on the shutdown sequence, preferably in some kind of visualization which is easy to understand.

The motivation is that for development and debugging of service files, it would be a lot more convenient to get this predicted list in advance, rather than having to do a real shutdown and then boot up again and inspect the logs every time I want to determine what impact a change to a service unit file or some other aspect of systemd's configuration will have on the shutdown order.

I was hoping that something like

systemctl list-dependencies --before shutdown.service

would do the job, but it only emits:

shutdown.service
9
задан 18 March 2016 в 03:05
3 ответа

Обычно порядок выключения является обратным порядку запуска.

Тем не менее, все демоны посылают сигнал выключения, и для фактического выключения и выхода потребуется разное количество времени.

Оставляя простую системуd, я не думаю, что можно с пользой предсказать, какие сервисы выйдут в какой последовательности. Далее, зависимости будут контролировать некоторые последовательности.

1
ответ дан 2 December 2019 в 22:37

Следующее может помочь вам:

systemctl list-dependencies --before shutdown.target

С уважением,

2
ответ дан 2 December 2019 в 22:37

Возможно, констатация очевидного уменьшает эффект обучения, но все, что я сделал, чтобы получить полный список обратных зависимостей для shutdown-target, как было задано в исходном посте, это:

systemctl list-dependencies --after shutdown.target

OT: Я столкнулся с проблемой, когда завершение работы системы kubernetes зависает (машина перестает отвечать на запросы и не выключается), потому что монтирование nfs завершается до завершения работы реальных служб. Этот вопрос помог мне продвинуться.

3
ответ дан 31 March 2021 в 12:25

Теги

Похожие вопросы