6

Is someone here able to start/stop/reload/... a list of units specified with a wildcard or similar method on systemctl?

I try do do somethin like: systemctl restart openstack-nova-*.services or systemctl restart openstack-nova-?.services

but it's a dead end and I didn't found anything usefull on systemctl's manual.

I could use a for loop but before that I'll have to make a systemctl -t service --failed and then grep for listed units... a little bit boring isn't ?

So, if someone know if it's possible to do something like that or not, I'll be happy to hear it.

If it's not, I think I'll push the idea on systemctl developers list or maybe do the patch if I have time to ^^

4
  • What about "systemctl restart openstack-nova*.service" ? Does it work?
    – dsmsk80
    Sep 23, 2013 at 8:39
  • Nop, that what I was talking about on my exemple indeed :( Thanks for your help!
    – Dr I
    Sep 23, 2013 at 8:43
  • What distro do you run?
    – dsmsk80
    Sep 23, 2013 at 8:43
  • I'm running on Fedora 19
    – Dr I
    Sep 23, 2013 at 10:02

2 Answers 2

3

UPDATE Systemd supports wildcards from systemd-209 forward https://serverfault.com/a/797926/291826


Two years later systemctl still doesn't allow wildcards, even though they would be extremely useful.

I did however take your note about systemctl -t service --failed and I hacked together this. I decided to post it here because the next person to find this question could be helped by it.

systemctl restart $(systemctl -t service --failed | grep openstack-nova-*.service | cut -d ' ' -f 1)

This takes systemctl -t service --failed, greps for the services matching "openstack-nova-*.service" and then removes the descriptors of those files by cutting (cut) on the space (-d ' ') and taking the first result (-f 1). Then it restarts the whole bunch because thankfully systemctl command allows for multiple services to be passed to it to stop.

1
  • Thanks a lot for your comment in this topic as it's really one of the most annoying missing features of systemctl. I have crafted a similar script myself to be able to perform this kind of operations. Anyway, I'm sure that your post will help a lot of people ;-) thank you very much!!
    – Dr I
    Jul 31, 2015 at 22:16
1

Soooo, to be noticed for people looking to manage multiple systemd units at same time. Since 2016 (2017?) Systemd is now accepting wildcard \o/

Exemple:

systemctl restart openstack-nova-* is now fully working

PS: At least it works on CentOS 7.x release (That's the only one that I tested).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .