Transfer only modified files by SCP

Hi all,

I want to transfer only modified files from one unix server to another unix sever ,tried hard but not succeeded please help me out to resolve it. The script is as below :wall:

ssh user@hostname <<EOT >files.txt
cd /x/y
find . -mtime -0 -type f |\
while read file
do
echo $file
scp -rp $file user@hostname2:/a/b/$file
done
EOT
$ find /your/file/path -mtime 0 -print | awk '{print "scp "$0" user@hostname:/a/b"}' | sh

Hi Jayan_ja
Thanks for your quick reply.
I have a,b,c folders and all folders are updated by new files all the day now i have to transfer these modified files to another unix server by SCP
1) script will find the modified files and send output to another file say output.txt
2)now it will transfer modified files using that output.txt file by SCP

any help will be appriciable
Thanks

find /your/file/path/to/a -mtime 0 -print > output.txt
find /your/file/path/to/b -mtime 0 -print >> output.txt
find /your/file/path/to/c -mtime 0 -print >> output.txt
awk '{print "scp "$0" user@hostname:/a/b"}' output.txt | sh

hi jay,

Thank you my problem is solved now

---------- Post updated at 08:59 AM ---------- Previous update was at 08:57 AM ----------

last one if i have to find files which are modified for last 15 minutes

mtime - ?

this will give you an idea ..

it is -mmin -15 for within 15 minutes.

Well I may be late here. But the below code do just the thing you want in single line:

find /path/to/a /path/to/b /path/to/c -type f -mmin -15 -print -exec scp {} 10.0.1.102:/path/to/copy/{} \; | tee -a ./output.txt

Hi,

(find /a/b/c -mmin -15 -print > output.txt
find: bad option -mmin)

I have root directory on server 1 say A and having sub directory B now my application generates output files and put in sub directory B.
now i need to transfer these files from server1 to server2 by scp which is having same directory structure A and sub directory B
I have tried a lot but seems need ur guidance.

Code:

STAMP=$(perl -e '($ss, $mm, $hh, $DD, $MM, $YY) = localtime(time() - 3600);
printf "%04d%02d%02d%02d%02d", $YY + 1900, $MM + 1, $DD, $hh, $mm')
touch $STAMP /A/B
find /A/B -type f ! -newer /A/B -print -exec scp -r {} server2:/A/B/{} \; | tee -a ./output.txt

or

find /your/file/path/to/a -type f -mtime 0 -print > output.txt
find /your/file/path/to/b -type  f -mtime 0 -print >> output.txt
find /your/file/path/to/c -type f -mtime 0 -print >> output.txt
awk '{print "scp "$0" user@hostname:/your/file/path/to/a /your/file/path/to/b /your/file/path/to/c"}' output.txt | sh