0kb file transferred in FTP process

We are transferring xml files to remote machine through cronjob @every 5 mins and then will move the files to the backup folder is source server.
Sometimes the file is transferred as 0kb to destination server, whereas the file in the source backup folder is completely written.

There is no error log recorded for the incomplete file transfer, so could you please help.

Is the file creation finished when the transfer starts?

See a similar thread from April first.

Yes I'm using the below code to check whether the opened or not in source server.

for v_file in `ls $1`
do
echo `ls -l $v_file` >> /home/oracle/ftp/file_size
FILEUSER=`/usr/sbin/fuser $v_file | cut -d ":" -f2 > /home/oracle/ftp/fileuser_check.log `
COUNT=`cat /home/oracle/ftp/fileuser_check.log  | wc -l`
if [ $COUNT -eq 0 ];
then
mv  $1/$v_file  $3
fi
done

Could you please help to check whether the file is opened or not in remote server.

You transferring the file from source computer to the remote computer.
But where does the file in the backup folder come from? The source computer directly, or transferred back from the remote machine?
You use the word folder instead of directory, are you aware that on Microsoft systems the output of a directory listing does not show files that are open for output, whereas Unix/Linux systems do.

Hi,

The file to the backup directory is moved from the source server once the ftp is completed.

"Not open" doen't necessarily mean "finished creating" a file. It's not uncomon that files are being opened for append in a split second, repeatedly, thus increasing in size but their writing not being reliably detectable.
Can you make sure the file is greater than 0kB in the moment of the transfer?

If there is a remote chance that your destination file is "open for write" when you are transferring, you should step back and reconsider your strategy. The results of neither the file transfer nor the remote file creation will be predictable with processes competing. Even reading a file when the transfer starts will not yield reliable results.