Is there a way to trigger a script once a file has been uploaded to an sftp directory, on an Ubuntu based server?

I was looking to see if there was a notion of ah ssh-trigger or ssh-hook, but I haven't been able to find anything that is ssh specific. The closest I have found is simply to watch the sftp folder via:

inotifywait -m /path -e create -e moved_to |
    while read dir action file; do
        echo "The file '$file' appeared in directory '$dir' via '$action'"
        # do something with the file

While I could use this approach, it would be nice to see something that is more specific to sftp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.