您现在的位置是:网站首页> 编程资料编程资料
Shell中使用plink工具实现远程批量关机_linux shell_
2023-05-26
339人已围观
简介 Shell中使用plink工具实现远程批量关机_linux shell_
我的操作系统是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
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脚本实现根据端口号kill相应进程功能_linux shell_
- Shell脚本编写Nagios插件监控程序资源占用_linux shell_
- 实时查看系统流量的Shell脚本分享_linux shell_
- Shell脚本自动备份MySQL到FTP并定期清理过期备份_linux shell_
- shell脚本监控系统负载、CPU和内存使用情况_linux shell_
- Nginx和PHP-FPM的启动、重启、停止脚本分享_linux shell_
- Shell脚本统计当前目录下目录和文件的数量_linux shell_
- Shell定时删除指定时间之前的文件_linux shell_
- Shell监控iptables运行状态_linux shell_
- Shell脚本实现监控swap空间使用情况和查看占用swap的进程_linux shell_
