ssh远程到目标机器执行命令shell脚本
来源:互联网 发布:vmware文件共享 ubuntu 编辑:程序博客网 时间:2024/05/22 02:14
linux下ssh到目标机器首先需要配置免密码登陆,才能执行如下脚本
hostnames服务器列表文件
master.hadoopw1.hadoopw2.hadoopw3.hadoopw4.hadoop运行shell脚本
#!/bin/bashfunction usage() { echo "Wrong arguments input..." echo "Usage: `basename $0` topicName handler[lookup|kill]" >&2 echo " eg: `basename $0` service_log lookup" exit 1}topic_array=("service_log" "service_log_nh" "service_log_agent" "service_log_flow" \ "service_log_rec" "search_log" "user_trace" "user_trace_internal")handler_array=("lookup" "kill")if [ $# -lt 2 ]; then usagefitopic=$1handler=$2## flume agent处理方式判断 if echo "${handler_array[@]}" | grep -w "$handler" &>/dev/null; then echo "Fount process handler: $handler"else echo "Not found process handler: $handler ...." usagefi## 判断是否为需要处理的flume agent名称if echo "${topic_array[@]}" | grep -w "$topic" &>/dev/null; then echo "Fount flume agent name: $topic"else echo "Not found flume agent name: $topic ...." usagefi## 根据handler名称处理flume agenthosts='hostnames' # hostname列表文件while read linedo hostname=$line echo "================ $hostname =============" case $handler in lookup) ssh root@$hostname -nq "ps -ef | grep flume | grep -w $topic | grep -v grep | wc -l" ;; kill) ssh root@$hostname -nq "ps -ef | grep flume | grep -w $topic |awk '{print $2}' |xargs kill -15" ;; *) usage ;; esacdone < $hosts
阅读全文
0 0
- ssh远程到目标机器执行命令shell脚本
- shell脚本ssh到其它机器上执行命令
- shell技巧--ssh远程执行包含nohup命令的脚本
- linux 通过shell脚本在本地执行远程机器命令
- ssh远程机器并执行命令输出到终端
- Java SSH远程执行Shell脚本实现
- Java SSH远程执行Shell脚本实现
- Java SSH远程执行Shell脚本实现
- Java SSH远程执行Shell脚本实现
- SSH远程连接执行shell脚本
- Java程序SSH远程执行Shell脚本
- Java SSH远程执行Shell脚本实现
- Java SSH远程执行Shell脚本实现
- SSH远程执行Linux Shell命令
- Python ssh 远程执行shell命令
- Linux远程ssh脚本执行命令问题
- 一个用ssh来远程登录多台机器并执行命令的脚本
- 使用shell脚本ssh远程执行命令,使用awk时总是报错
- nsis语法解析
- Spring Security学习笔记(二)——访问数据库(一)
- AD中layer与plane区别
- git学习笔记
- 软件中的质量属性(二)
- ssh远程到目标机器执行命令shell脚本
- asp.net快速开发平台:开发界的网红制造机
- MySQL使用总结
- android so文件的引用以及遇到的坑
- spring汇总.md
- 一个Java进程直接死掉的问题分析
- 15.计算数组中3个数和为0的不重复的组合
- MacBook:phpmyadmin [2002] No such file or directory修复
- [define的用法]define用法集锦