使用scp 批量上传文件 并使用md5校验
脚本第一个参数 需要上传的文件
脚本第二个参数 需要保存的目录
#!/bin/bash# 参数1 为需要上传的文件file=$1# 参数2 为上传后的目录地址, 默认为/opt/orderbot/dest=${2:-/opt/orderbot/}# 生成md5校验文件md5sum $file > $file.md5for i in {2..15}doecho "upload to node${i}"# 上传md5校验文件scp -o 'StrictHostKeyChecking no' -i ~/.ssh/stephen $file $file.md5 node$i:$dest;# 上传文件并且校验md5ssh -o 'StrictHostKeyChecking no' -i ~/.ssh/stephen node$i "cd $dest; md5sum -c $file.md5"if (($? != 0))thenexit 1fidone
