I have a service that stopped suddenly. I tried to restart that service but failed and asked to run "systemctl daemon-reload".

What it exactly do? What is a "daemon reload?"

  • 3
    I wonder: Did you try man systemctl before asking?
    – U. Windl
    Feb 10 at 13:35
  • 6
    I'm a huge fan of man pages, but as the detailed answer below illustrates, it is sometimes worth asking these simple questions; a huge and sufficiently complex project can have a long documentation for one to easily get lost in, and/or the text may not cater towards one's current knowledge level.
    – toraritte
    Jul 1 at 19:31

man systemctl says:

       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.

       This command should not be confused with the reload command.

So, it's a "soft" reload, essentially; taking changed configurations from filesystem and regenerating dependency trees.

Consequently, systemd.generator states:

Generators are small binaries that live in /usr/lib/systemd/user-generators/ and other directories listed above. systemd(1) will execute those binaries very early at bootup and at configuration reload time — before unit files are loaded. Generators can dynamically generate unit files or create symbolic links to unit files to add additional dependencies, thus extending or overriding existing definitions. Their main purpose is to convert configuration files that are not native unit files dynamically into native unit files.

   Generators are loaded from a set of paths determined during compilation, listed above. System and user
   generators are loaded from directories with names ending in system-generators/ and user-generators/,
   respectively. Generators found in directories listed earlier override the ones with the same name in
   directories lower in the list. A symlink to /dev/null or an empty file can be used to mask a generator,
   thereby preventing it from running. Please note that the order of the two directories with the highest
   priority is reversed with respect to the unit load path and generators in /run overwrite those in /etc.

   After installing new generators or updating the configuration, systemctl daemon-reload may be executed. This
   will delete the previous configuration created by generators, re-run all generators, and cause systemd to
   reload units from disk. See systemctl(1) for more information.
  • I am wondering why would one want to put this in a daily cron job see github.com/cri-o/cri-o/issues/2584 . he claims it is an overflow issue in systemd github.com/systemd/systemd/issues/11809 I would like to understand why it is needed and why it happened
    – Hend
    Mar 25 '20 at 11:07
  • 1
    I haven't looked into this in great detail, I could only speculate that the idea there is to try to force a "soft reload" using cron. I'm not sure if that's necessary, or how effective that is. The bug you linked to is shown to have been fixed. So, maybe they use older version of systemd. Again, merely speculating. You could try asking a new question with those references and a pointer to this question perhaps.
    – ILMostro_7
    Mar 26 '20 at 22:50
  • I'm wondering if it would be okay to always automatically systemctl daemon-reload run when inotify detects that some config file has been modified... Jan 23 at 15:56

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.