Many thanks for the quick response. Please find the run method from the TimerTask below.
The debug log currently goes to the console so I can't include that - suffice to say there's nothing in it after my own "Connecting to ..." logging message. What I usually get immediately after the "Connecting to ..." message on a successful run is obviously a "DEBUG ... 220 ... Ready" message. By the way, my "Task complete" logging message from the last successful run before the hung run was issued 59 seconds before the final "Connecting to ..." message. Hope that's clear!
Regards and thanks,
fpr
public void run() {
String filename;
long size1, size2;
GregorianCalendar D1=new GregorianCalendar(), D2;
File lock;
lock=new File(this.lockfile);
try {
if (!lock.createNewFile()) {
if (this.loggerset) {this.logger.log(Level.INFO, "Lockfile "+this.lockfile+" already exists");}
}
else {
try {
if (this.loggerset) {
this.logger.log(Level.INFO, "Connecting to "+this.ftpsite);
}
this.ftp=new FTPClient(this.ftpsite);
this.ftp.setTimeout(this.timeout);
this.ftp.login(this.username, this.password);
this.ftp.setType(FTPTransferType.BINARY);
String [] list=this.ftp.dir("");
if (list.length!=0) {
if (this.loggerset) {
this.logger.log(Level.INFO, "Server "+this.ftpsite+" contains "+list.length+" files");
}
}
this.file_list=new String[list.length];
for (int i=0;i<list.length;i++) {
this.remote_file=list[i];
this.local_file=outdir+System.getProperty("file.separator")+list[i];
this.file_list[i]=this.local_file;
size1=1;size2=0;
while (size1!=size2) {
size1=this.ftp.size(this.remote_file);
D1=new GregorianCalendar();D2=new GregorianCalendar();D2.add(D2.SECOND,2);
while (D1.before(D2)) {
D1=new GregorianCalendar();
}
size2=this.ftp.size(this.remote_file);
}
if (this.loggerset) {this.logger.log(Level.INFO, "Transferring remote file "+this.remote_file+" to "+this.local_file);}
this.ftp.get(this.local_file, this.remote_file);
//this.ftp.delete(this.remote_file);
this.fileProcess(this.local_file);
}
this.listProcess(this.file_list);
}
catch (Exception e) {
SimpleDateFormat sdf=new SimpleDateFormat("HH:mm zzz, dd MMMMMMMMM yyyy");
if (this.loggerset) {this.logger.log(Level.WARNING, "ftp error occurred during connection to "+this.ftpsite+" at "+sdf.format(new Date()), e);}
}
finally {this.ftp.quit();}
}
}
catch (Exception e) {
if (this.loggerset) {
this.logger.log(Level.WARNING, "Could not create lockfile "+this.lockfile);
}
}
if (!lock.delete()) {
if (this.loggerset) {
this.logger.log(Level.WARNING, "Could not delete lockfile "+this.lockfile);
}
}
lock.deleteOnExit();
this.logger.log(Level.INFO, "Task complete");
}