Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to compare the modified date of a local file and the equivalent file on a remote FTP site (via FTP, no SSH access). I'm using Python's ftplib btw. The only way I can find to get the remote modified date is by using the dir command, but that doesn't output the year. Using gFTP shows the year in the modified date, so there must be a way of getting that information. Any ideas?

share|improve this question
up vote 2 down vote accepted

If your FTP server supports it, you could try using the MDTM command. This returns the file modification time in the format YYYYMMDDHHMMSS.sss. The milliseconds are optional and the time is in GMT.

It doesn't look like ftplib supports MDTM directly, but you should be able to call it with sendcmd:

ftp.sendcmd('MDTM filename')
share|improve this answer
Excellent! That was exactly what I was looking for. Thanks very much. – Skilldrick Jan 30 '10 at 14:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.