Is there a way to run a script over a file that has been uploaded on an FTP server.

I am running ProFTP on the server and would like to process the uploaded files immediately after they are uploaded. The ways I have currently thought of are

  1. Cron Job to find new files in the FTP and process them every minute.
  2. Write a daemon to monitor the file upload log and use that information to process the file.

Is there a better way, or a directive I can set on the server to run a script on all file uploads?

Update: Linux OS


You don't state your OS, but if you're on a Linux box, you can hook 'inotify', which will is a kernel subsystem that fires when filesystem events happen. This should give you much better response time than cron, which only runs on one minute granularity.

The following link will get you started, but there are Perl, Python, and a bunch of other bindings available.



If changing your ftp daemon is not a problem then pure-ftpd has this functionnality.

Hope this helps.

  • I use PureFTPd and this functionality. – DejanLekic Nov 2 '15 at 16:13

The two general approaches to this would be:

  1. Use functionality built-in to ProFTP (if it exists) or another FTP server product
  2. Have some operating system process or cron job (as you mentioned in both your #s 1 and 2) watch for the file, or better than polling is to watch for file system events and respond accordingly. See https://stackoverflow.com/questions/324258/is-there-an-equivalent-to-the-net-filesystemwatcher-in-the-linux-world.

The easiest approach is to use functionality built in to the FTP server if it exists. If not, you can likely download file watcher code and or an already-written shell script which you can cron.

Your Answer

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

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