I have an SFTP server (debian ssh server) where remote users are uploading once a while one big file into a specific directory.
My challenge is that I need to detect:
1) that a new file is present.
2) that the upload process/transmission is done.
What would be the best way to do this? Maybe there is already some tools available for this?
Logically thinking I can maybe detect in a first phase that a new file is present in the directory. And in a second phase then loop/wait until the user SFTP disconnects!? After that I could fire the next process…
Thx & cheers,
Peter
For problem 1) you can use the
inotifyAPI to watch the directory for changes. You don’t say which programming language you use. In Perl you would useLinux::Inotify, in Pythonpynotify.For problem 2), one way is to wait until the ssh session disconnects, another is to also use
inotifyto watch for file close notifications.