232

Let's say I write a mine.service file. Then I use systemctl enable mine.service.

If I later decide to edit mine.service, do I have to tell systemd that mine.service was changed? If so, how do I do that?

2 Answers 2

278

After you make changes to your unit file, you should run systemctl daemon-reload, as outlined here.

daemon-reload
Reload systemd manager configuration. This will rerun all generators (see systemd.generator(7)), reload all unit files, and recreate the entire dependency tree. While the daemon is being reloaded, all sockets systemd listens on behalf of user configuration will stay accessible.

You can then restart (or reload) your service as you desire with

systemctl restart your-service-name

(daemon-reload won't reload/restart the services themselves, just makes systemd aware of the new configuration)

5
  • 3
    I found I also needed to run a systemctl restart to actually restart the service itself...
    – hwjp
    Oct 4, 2016 at 20:52
  • 15
    Just in case, daemon-reload isn't universal, have got to run systemctl --user daemon-reload for user services.
    – Alec Mev
    Jan 25, 2018 at 22:06
  • As a note it also "delete the previous configuration created by generators" before rerunning them: freedesktop.org/software/systemd/man/systemd.generator.html
    – rogerdpack
    May 9, 2019 at 17:22
  • Bit of a syntax complaint but should != must. And must it is, which feels lame because systemctl is smart enough to tell you that you need to reload it, but won't reload itself.
    – Kevin
    Mar 4, 2021 at 6:08
  • Yeah, you’re absolutely right, it does need to be run after changing a unit.
    – GregL
    Mar 4, 2021 at 18:52
32

As an addition to the answer above: In case you changed something in the [Install] directive, you may need to run sudo systemctl reenable YOURUNITFILE in order to recreate the symlinks in the .target directories.

1
  • This did the trick for me! Didn't get it why systemctl wasn't reloading the service file. Sep 21, 2018 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.