Unanswered: Pull only new files from Server A to Server B
I am very new to shell scripting and need to create shel script for following :
Look continuously for new files in server A(/hosting/apps) and as they arrive pull it to server B (/hosting/landing).
Note - only new files that have arrived in server A should be pulled into Server B. Script resides on Server B.
Also Server A is FTP only and RSYNC wont work.
Expecting to have 70 files dropped in a day on server A all starting with TTY_*
How frequently do you want to check for new files?
Assuming that both machines are unix/linux, the danger is that you will attempt to copy a file that is still in the process of being written, and only retrieve a portion of the file.
Is machine B allowed to rename/move/create files on machine A?
Do you have any control over the creation of files on machine A?
Is there a reason that you cannot push the files from machine A to B?
if [ -r ftp.pid ]
echo previous invocation still running
echo $$ >ftp.pid
ftp A <<EOF >A.list
./createnewlist.ksh <A.list >new.list
ftp A <new.list
If you can use .netrc files to store the userid and password, the script to compare the list of files on A and the ones that you already have will be simpler, and you will not have to put the userid and password in the new.list file.
The sleep for 10 seconds should allow any files that are being created while you are listing them to complete by the time you go back to get them.
Your application process should append files that you have successfully processed to your done list, giving you an opportunity to re-retrieve any files that did not process the first time.
createnewlist.ksh should look like:
while read perms x own size month day time file
grep $file done.list
if [ $? != 0 ]
echo get $file >>new.list
echo quit >>new.list
You may have to add additional reads or logic depending on the actual contents of A.list