手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >Shell中使用plink工具实现远程批量关机
Shell中使用plink工具实现远程批量关机
摘要:我的操作系统是centos6.4操作系统:rhel6.2x86_64下载并安装putty软件包,本人下载了putty-0.62-1.el6....

我的操作系统是centos6.4

操作系统:rhel 6.2 x86_64

下载并安装putty软件包,本人下载了putty-0.62-1.el6.rf.x86_64.rpm

下载地址如下:http://rpm.pbone.net/index.php3

1、远程主机IP列表文件

复制代码 代码如下:

[root@localhost~]# vim server_list.txt

192.168.0.13

192.168.0.12

192.168.0.11

2、远程主机要执行的操作的文件

复制代码 代码如下:

[root@localhost~]# vim shutdown.txt

shutdown -h now

3、远程关机自动化脚本

复制代码 代码如下:

[root@localhost~]# vim remote_shutdown.sh

for i in `cat server_list.txt`

do

plink -l root $i -pw redhat -m /shutdown.txt <<EOF

y

EOF

done

4、脚本赋予执行权限x

复制代码 代码如下:

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

5、脚本运行

复制代码 代码如下:

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

注意:本人应用环境,所有主机root用户密码均为redhat,请根据实际环境调整,若无规律,可单条列出。

例如:

复制代码 代码如下:

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

(或 plink root@192.168.0.19 -pw password4 -m /shutdown.txt)

【Shell中使用plink工具实现远程批量关机】相关文章:

Shell脚本学习指南之文本处理工具

Linux Shell脚本系列教程(四):使用函数添加环境变量

Shell脚本实现简单分割字符串

Bash Shell中忽略大小写的设置方法

Shell脚本批量清除Nginx缓存

Shell脚本实现的单机流量统计功能

使用iconv批量改变文件编码的shell脚本

Shell实现的iptables管理脚本分享

Shell脚本实现防止国外ip访问服务器

Shell中的for和while循环详细总结

精品推荐
分类导航