0

I want to kill all instances of a systemd service.

This works fine: sudo systemctl stop 'custom-service@*' but it is slow since it runs my custom ExecStop which does extra work to safely shut down the process.

In certain cases, I'd rather just kill the processes. I tried to do it this way sudo systemctl kill -s SIGKILL 'custom-service@*' however, this doesn't kill anything.

If I modify this to a specific instance it works fine and the instance gets killed. e.g. sudo systemctl kill -s SIGKILL 'custom-service@someinstance-1.service' but I'd rather not do that for each one.

Have I missed something?

zzbomb
  • 103
  • 3

1 Answers1

1

Just use systemd stop. In general it's not a good idea sending SIGKILL to any systemd units. Also if you read man systemd.kill it only works on one particular unit at a time, no globs.

Danila Ladner
  • 5,331
  • 22
  • 31
  • This seems fair, I've gone ahead and switched to just use stop. It's not really what I wanted but it works well enough for my scenario. – zzbomb Apr 28 '21 at 18:10
  • No. This is incomplete, erroneous instruction. "systemd stop" results in "Excess arguments." – Bob Feb 23 '23 at 14:03