CentOS7:使用一个命令重新启动服务的多个实例

CentOS7:使用一个命令重新启动服务的多个实例

有没有办法只使用一个命令重新启动 systemd 中服务的所有实例?

假设我们有两个正在运行的守护进程,分别名为 thingd@01 和 thingd@02。我可以只重启它们,而不必对每个实例调用一次 systemctl 吗?

答案1

您应该能够使用一个 systemctl 重新启动它们,只需在服务之间留一个空格即可。例如systemctl restart thingd@01 thingd@02

在将实例从负载平衡池中移除后,我通常会在克隆实例之前停止所有主要服务。我使用以下方法:

# 停止 php-fpm、MariaDB、nginx 和 postfix

systemctl stop php-fpm nginx postfix mariadb

# 停止后检查状态

systemctl status php-fpm nginx postfix mariadb

# 重新开始所有操作

systemctl start php-fpm nginx postfix mariadb

相关内容