This experiment is passed in the Centos/RHEL system. For other versions of linux/Unix, you only need to make appropriate modifications. This script requires that the SSH service must be enabled on the Unix-like server you manage, public and Private keys are set for automatic login. for more information, see auto login for ssh.
#! /Bin/bash
# ByService-Labshttp: // www.service.labs.com
# Using an array to store SSH commands for each server
Hosts = (
"Ssh root@www.service-labs.com yum update-y"
"Ssh root@bak.service-labs.com-p 222 yum update-y"
"Ssh mail@mail.service-labs.com-t sudo '/usr/bin/yum update-y '"
"Ssh root@192.168.33.22 yum update-y"
"Ssh root@192.168.0.25-p 5006 yum update-y"
"Ssh root@192.168.35.4-t sudo '/usr/bin/yum update-y '"
)
# Reading arrays and executing ssh commands
For sshcmd in "$ {hosts [@]}"; do $ sshcmd; done
Put the above script in cron for scheduled execution. If you manage many servers, using this shell script can save you a lot of time!