12

Is there a way of restarting all instances of a service in systemd using only one command?

Suppose we have two daemons running called thingd@01 and thingd@02. Can I restart just those without having to resort to making one call to systemctl per instance?

23

You should be able to restart both of them with one systemctl, just put a space between the services. E.g. systemctl restart thingd@01 thingd@02

I usually stop all major services before cloning an instance after it has been removed from a load balanced pool. I use the following:

# stop php-fpm, MariaDB, nginx and postfix

systemctl stop php-fpm nginx postfix mariadb

# check status after they have been stopped

systemctl status php-fpm nginx postfix mariadb

# start all of them again

systemctl start php-fpm nginx postfix mariadb
3
  • 4
    That works! also... systemctl restart thing@{1..8} seems to work with it. Thank you @mstephenson. Apr 4 '16 at 22:02
  • @user1096824 if this has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this.
    – Sufian
    Jul 19 '19 at 10:39
  • 1
    For stop or restart also possible systemctl stop 'thing*'. Also systemd target could be used to group multiple instances.
    – dess
    Jan 14 '20 at 22:04

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.