brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: systemctl daemon-reload comes after every unit file you edit by hand

Systemctl
~/tips/tip-systemctl-daemon-reload

sudo systemctl daemon-reload

Load unit file changes before you restart the service.

You change a unit file in a text editor, restart the service, and it behaves exactly as before. systemd is still working from the copy it loaded earlier.

Tell it to read the files again, then restart:

sudo systemctl daemon-reload
sudo systemctl restart myapp.service

daemon-reload reloads the configuration of systemd itself, which includes all unit files and drop-ins. It does not restart anything, so running services carry on with their old settings until you restart them. That is why I always type the two lines together.

You need it after creating a new unit in /etc/systemd/system, editing one by hand, deleting one, or copying one in from a script. systemctl edit does the reload for you when you save, and so do enable and disable.

A status output that warns about the unit file having changed on disk is the clue that you skipped this step.

For units in your own session, the command is systemctl --user daemon-reload, without sudo. The system one does not see them.

Don’t confuse it with systemctl reload myapp. That asks the running program to read its own config again and has nothing to do with unit files. A typo in the unit also survives a reload quietly, so check the status afterwards.

Further reading: systemctl man page

More Systemctl tips systemctl list-units --type=service --state=running systemctl -H [email protected] status nginx sudo systemctl reboot --firmware-setup systemctl list-jobs sudo systemctl try-restart nginx.service All Systemctl tips (9) All topics

Link