如何从Unix服务器到另一台Unix服务器获取最新的文件?
我已通过SFTP连接到服务器2并尝试应用for循环来检查时间戳,这不起作用:
sftp $SERVER2 << !EOF
cd $Server2_FILE_LOCATION
echo Pwd File location: $pwd
LastUpdatedTS=$(grep "value of TimeStamp is" /root/airtelSnD/BoTreeScript/BotreeLastFileTS.txt | cut -d'=' -f2)
echo 1
for file in mad_*.*
do
CurrentFileTS=$(stat -c %Y $file |awk '{print strftime( "%Y%m%d%H%M%S", $1 )}')
echo 2
echo TS of last updated file is : $LastUpdatedTS
echo value CurrentFileTS is $CurrentFileTS
echo 3
if [[ $CurrentFileTS -gt $LastUpdatedTS ]]
then
echo if......
mget $file $DESTINATION_SERVER
echo value of TimeStamp is=$CurrentFileTS > $LASTFILE_TS
else
echo else...
fi
done
quit
!EOF
bolD对以下问题的回答可能会让你感兴趣:scp-without-
—
replacement
sftp
的环境。(它看起来像$Server2_FILE_LOCATION
和$DESTINATION_SERVER
对其中适用唯一的。)