Home  >  Q&A  >  body text

linux - bash 远程ssh 获取进程id并kill

现在有50台机器

想写一个bash,分别访问每台机器,kill掉相同的程序,并清空data文件夹内容,然后重启集群服务

这个bash要怎么写?

大家讲道理大家讲道理2724 days ago1010

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-17 15:52:55

    fori(ip):
        ssh -n -T $ip/$hostname 'ps -ef|grep ${your process}|awk '{print $2}|xargs kill -9 && rm ${your data's path}'
    
    ssh ${your master machine} '${run restart.sh}'

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 15:52:55

    Just use expectto implement it
    Automatically log in to each server, and then the rest will be simple. .

    reply
    0
  • Cancelreply