« Back to Systemd: Frequently Asked Questions

How to check if 'systemctl daemon-reload' is needed

This article has last been updated at .

How to check if 'systemctl daemon-reload' is needed?

Use systemctl to show the NeedDaemonReload property of the specific unit.

systemctl show --property=NeedDaemonReload --value UNIT

Systemd may need to reload a part of the unit configuration if changes were made. To find out if the related systemctl daemon-reload command is needed, the state of the individual units can be tested. This is done by querying the property using the --property=NeedDaemonReload option.

Testing a single service like nginx, can be done this way:

# systemctl show --property=NeedDaemonReload --value nginx.service
yes

This output will return a ‘yes’ or ’no’ value.

Check all services

In need for a one-liner to check if there is any service that was changed and requires systemctl to initiate the daemon-reload?

# for UNIT in $(systemctl list-units --type=service --all --legend=false --plain | awk '{print $1}'); do if [ "$(systemctl show --property=NeedDaemonReload --value "${UNIT}")" = "yes" ]; then echo "$UNIT is outdated, systemctl daemon-reload needed"; fi; done
nginx.service is outdated, systemctl daemon-reload needed

Learn more about systemctl

This article uses the systemctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: systemctl

systemctl

Other questions related to Systemd

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.