What does "systemctl daemon-reload" do?

  • 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?"

  • man systemctl says:

       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.
    
           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 https://github.com/cri-o/cri-o/issues/2584 . he claims it is an overflow issue in systemd https://github.com/systemd/systemd/issues/11809 I would like to understand why it is needed and why it happened

    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.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM