{"id":973,"date":"2021-03-29T15:24:49","date_gmt":"2021-03-29T07:24:49","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=973"},"modified":"2021-03-29T15:24:49","modified_gmt":"2021-03-29T07:24:49","slug":"linux-file-distribution-synchronization-script-from","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2021\/03\/linux-file-distribution-synchronization-script-from\/","title":{"rendered":"Linux \u6587\u4ef6\u5206\u53d1\u540c\u6b65\u811a\u672c\uff08\u6765\u81ea\u5c1a\u7845\u8c37\u6559\u7a0b\uff09"},"content":{"rendered":"
#!\/bin\/bash\n\n# \u5224\u65ad\u53c2\u6570\u4e2a\u6570\nif [ $# -lt 1 ]\nthen\n echo "\u6ca1\u6709\u4f20\u9012\u53c2\u6570\uff01"\n exit;\nfi\n\n# \u904d\u5386\u7fa4\u96c6\u6240\u6709\u673a\u5668\nfor host in 64.115.3.30 64.115.3.40 64.115.3.50\n#for host in 64.115.5.32 64.115.5.158\ndo\n echo "============================= $host ==========================="\n #\u904d\u5386\u6240\u6709\u76ee\u5f55\uff0c\u6328\u4e2a\u53d1\u9001\n for file in $@\n do\n #\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728\n if [ -e $file ]\n then\n #\u83b7\u53d6\u7236\u76ee\u5f55\n pdir=$( cd -P $(dirname $file ); pwd )\n #\u83b7\u53d6\u5f53\u524d\u6587\u4ef6\u7684\u540d\u79f0\n fname=$(basename $file)\n ssh $host "mkdir -p $pdir"\n rsync -av $pdir\/$fname $host:$pdir\n else\n echo "$file \u4e0d\u5b58\u5728\uff01"\n fi\n done\n\ndone\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"#!\/bin\/bash # \u5224\u65ad\u53c2\u6570\u4e2a\u6570 if [ $# -lt 1 ] then echo "\u6ca1\u6709<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,14],"tags":[],"yoast_head":"\n
Linux \u6587\u4ef6\u5206\u53d1\u540c\u6b65\u811a\u672c\uff08\u6765\u81ea\u5c1a\u7845\u8c37\u6559\u7a0b\uff09 - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n\n\n\n\n\n\n\n\n\n\n\n