CentOS7: Restart multiple instances of a service with one command

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?


Solution 1:

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