Use Plink tool in Shell to implement remote batch shutdown _linux Shell

Source: Internet
Author: User

My operating system is centos6.4.

Operating system: Rhel 6.2 x86_64

Download and install the Putty software package, I downloaded the putty-0.62-1.el6.rf.x86_64.rpm
Download the address below: HTTP://RPM.PBONE.NET/INDEX.PHP3

1. Remote Host IP list file

Copy Code code as follows:

[root@localhost~]# Vim Server_list.txt

192.168.0.13
192.168.0.12
192.168.0.11


2, the remote host to perform the operation of the file
Copy Code code as follows:

[root@localhost~]# Vim Shutdown.txt

Shutdown-h now

3. Remote Shutdown Automation Script

Copy Code code as follows:

[root@localhost~]# Vim remote_shutdown.sh

For i in ' Cat server_list.txt '
Todo
Plink-l root $i-pw redhat-m/shutdown.txt <<eof
Y
Eof
Done


4, the script gives execution permission X
Copy Code code as follows:

[root@localhost~]# chmod a+x remote_shutdown.sh

5. Script running
Copy Code code as follows:

[root@localhost~]#./remote_shutdown.sh

Note: I apply the environment, all the host root user password is redhat, please adjust according to the actual environment, if irregular, can be listed as a single.

For example:

Copy Code code as follows:

Vim remote_shutdown.sh

Plink-l Root 192.168.0.12-PW password1-m/shutdown.txt
Plink-l Jane 192.168.0.35-PW password2-m/shutdown.txt
Plink-l Paul 192.168.0.77-PW Password3-m/shutdown.txt
Plink-l Root 192.168.0.19-PW password4-m/shutdown.txt

(or Plink root@192.168.0.19-pw password4-m/shutdown.txt)

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.