Shell scripting implements managing multiple servers at the same time

Source: Internet
Author: User

Shell scripting to manage multiple servers at the same time, without the use of ansible, automatic manual implementation

SSH does not log on to the Machine execution command (if you have to implement password-free login)
ssh 127.0.0.1 ‘ifconfig‘ssh 127.0.0.1 ‘ifconfig|grep bbb‘ssh 127.0.0.1 ‘tail /var/log/secure‘
Shell while looping through the IP list of servers that need to be managed
cat /tmp/hosts|while read line;doecho $line;done
Combine these two implementations to manage multiple servers at the same time
    • The first idea, but no way to manage multiple servers at the same time, can only manage 1 units
      cat /tmp/hosts|while read line;doecho $linessh $line ‘tail /var/log/secure‘done
    • A try to hit the log, or not
      cat /tmp/hosts|while read line;doecho $linessh $line ‘tail /var/log/secure‘ >/tmp/${line}.logdone
    • Try to succeed, must be placed in the background &

      cat /tmp/hosts|while read line;doecho $linessh $line ‘tail /var/log/secure‘ >/tmp/${line}.log &done

      SSH no password, SCP is also no password.

      Combined with the above, we have been able to manage multiple servers simultaneously, batch run commands, batch upload files, bulk download files.

Shell scripting implements managing multiple servers at the same time

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.