FTP client is hanging very rarely!

Hi,

I have a script in which I am using ftp to transfer some files from remote -> local and vice versa, this scripts is invoked by cron. for your reference I am sharing the function also :

=============================================

fn_FileTransfer_LocalToRemote() 
{
	set -x
	ftplog=${FTP_LOG}

	ftp -v -n ${1} <<EOF > $ftplog
	open ${1}
	user ${2} ${3}
	cd ${5}
	pwd
	lcd ${4}
	binary
	put ${6}
	bye
EOF
}

================================================

Now my problem here is that I can see some of the hanged client ftp processes when I issue "ps -ef | grep ftp" but this is very rare and till now it happend only 3 times while this is running from a long time.

I have checked in FTP server, I can not see any socket connection established for client, but at client side I can see.

Any idea what is going wrong?

Thanks,
Anshuman

If you replaced:

	ftp -v -n ${1} <<EOF > $ftplog

with

	ftp -v -n ${1} <<EOF >> $ftplog 2>&1

Then each run will append the log file and the error message will go into the log file also so you can then see what happened several cron runs ago.
It would then be advisable to use logrotate(8) or something similar to roll the log file at regular intervals.