Linux远程文件拷贝
#!/bin/sh ################################################################################ ######把10.0.64.224主机上/data/sea/upload/底下文件拷贝到10.10.31.79############# ######文件拷贝成功后,把文件从10.0.64.224主机上删除,本地记录操作日志############# ################################################################################ #远程主机地址 remote_ip=10.0.64.224; #远程主机登录用户 remote_user=root; #远程主机目录 remote_path="/data/sea/upload"; #本地保存远程拷贝文件目录 local_path="/usr/data/upload/ftpupload"; #本地日志文件输出目录 log_dir="/home/web_sea/logs"; log_file_date=`date +%F`; for file in `ssh ${remote_ip} ls ${remote_path}` do scpfile="scp ${remote_user}@${remote_ip}:${remote_path}/${file} ${local_path}/"; $scpfile; log_date=`date +%F" "%T`; if [ $? -eq 0 ] ; then echo "$log_date debug scp file [$file] is successfully" >> $log_dir/access_${log_file_date}.log ssh ${remote_ip} rm -rf ${remote_path}/${file} if [ $? -eq 0 ] ; then echo "$log_date debug delete file [$file] is successfully" >> $log_dir/access_${log_file_date}.log else echo "$log_date error delete file [$file] is failure" >> $log_dir/error_${log_file_date}.log fi else echo "$log_date error scp file [$file] is failure" >> $log_dir/error_${log_file_date}.log fi done
相关推荐
competeking 2020-07-04
thunderstorm 2020-07-04
Catastrophe 2020-06-11
云之飞踢 2020-05-20
JF0 2020-05-08
houjinkai 2020-01-12
tanyhuan 2020-01-08
DonviYang 2020-01-07
aolishuai 2020-01-05
muzirigel 2019-12-28
CharlesYooSky 2019-12-24
kuwoyinlehe 2019-12-18
JF0 2019-11-29
xiaohouye 2019-11-11
natejeams 2008-01-21
Rain 2019-11-03