« Back to Systemd: Frequently Asked Questions

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

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 cheat sheet

Other questions related to systemd

Feedback

Is the described answer not working or incorrect, got another tip or question? Share your thoughts!