the --now switch of `systemctl`

19,724

I've found that annoying as well.

Looks like the --now switch was added in version 220 (see this line in the changelog), and CentOS 7 is currently on version 219. Hopefully soon then!

You can check your version of systemd with systemctl --version.

Share:
19,724

Related videos on Youtube

Martin Schröder
Author by

Martin Schröder

Updated on September 18, 2022

Comments

  • Martin Schröder
    Martin Schröder over 1 year

    As stated in the man page,

    systemctl --now enable servicename
    

    should enable and start the service.

    But it never works for me, under many different distributions.

    While the output of:

    systemctl is-enabled turns enabled,

    systemctl is-active is still inactive for the service.

    What this switch is good for?

    I've tried other combinations such as:

    systemctl enable --now servicename
    

    and:

    systemctl enable servicename --now
    

    but still the same; I have to manually systemctl start servicename every time, even if the previous command (ie the enable part) executes successfully.

    Is it that the application's implentation of systemd service should support it implementing the feature somewhere in the unit files; what many well-known services do not follow, that made me think its entirely useless switch; I assume thinking over it.

    • Admin
      Admin almost 7 years
      All "combinations" work fine here (archlinux).
  • pzkpfw
    pzkpfw about 5 years
    FYI I am on CentOS 7 and # systemctl --version tells me I'm using systemd 219 but I have verified that the --now flag indeed starts a stopped service. Maybe RHEL/CentOS backporting?
  • Prashant Lakhera
    Prashant Lakhera about 5 years
    Hi @pzkpfw same for me, even I am on 219 and --now works for me.