WJA
WJA

Reputation: 7004

How can I listen for changes on a (S)FTP server?

I am downloading intra-daily files from several (S)FTP servers. These servers are not managed by me, I have been granted access by external parties.

The files arrive at different points of time in the day. I cannot therefore not know beforehand when I have to send an extraction request.

Is there a smart way to setup a listener to track changes on these SFTP server? Eg some kind of ping that returns the last updated timestamp of the server.

Upvotes: 2

Views: 2818

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202272

First, FTP and SFTP are two completely unrelated protocols. So it does not make sense to ask for both in one question. Anyway, the answer is actually pretty much the same for both.


Neither FTP nor SFTP protocol have any mechanism to notify a client about changes.

They do not even have a way to report the changes on a request.

All you can do is to periodically list all files on the server and compare the list against previous results.

With FTP, it can be slightly optimized by asking for a list sorted by timestamps. This way, particularly if there are lot of files in a folder, you can abort a list download, once you get all new files. Though asking for a sorted list is a non-standard function, while widely supported. See How to get files in FTP folder sorted by modification time.


Had you control the server (the machine, not the software), you might build a service there that will provide the information you need. But that has nothing to do with SFTP/FTP. And as you do not control the server, it's not relevant either.


Similar recent question: Incremental scan of new/modified FTP files with C#

Upvotes: 2

Related Questions