广告
返回顶部
首页 > 资讯 > 服务器 >Shell中使用plink工具实现远程批量关机
  • 690
分享到

Shell中使用plink工具实现远程批量关机

批量实现远程工具 2022-06-04 21:06:12 690人浏览 八月长安
摘要

我的操作系统是Centos6.4 操作系统:rhel 6.2 x86_64 下载并安装putty软件包,本人下载了putty-0.62-1.el6.rf.x86_64.rpm 下载地址如下:Http:/

我的操作系统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)

--结束END--

本文标题: Shell中使用plink工具实现远程批量关机

本文链接: https://www.lsjlt.com/news/18295.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Shell中使用plink工具实现远程批量关机
    我的操作系统是centos6.4 操作系统:rhel 6.2 x86_64 下载并安装putty软件包,本人下载了putty-0.62-1.el6.rf.x86_64.rpm 下载地址如下:http:/...
    99+
    2022-06-04
    批量 实现远程 工具
  • Shell中怎么利用plink工具实现远程批量关机
    Shell中怎么利用plink工具实现远程批量关机,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。1、远程主机IP列表文件代码如下:[root@localhost...
    99+
    2023-06-09
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作