Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

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.

http://inotify-tools.sourceforge.net

share|improve this answer

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

Hope this helps.

share|improve this answer

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 http://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.

share|improve this answer

Your Answer

 
discard

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.