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.

I have an application that needs to process large files after they are uploaded to the system. In Linux, is it possible to detect folder changes and have a script run automatically, or should I just run a cron job every minute to look for new files?

share|improve this question
    
You may have more luck with this question on StackOverflow. –  John Gardeniers Aug 3 '09 at 0:13
add comment

4 Answers 4

up vote 6 down vote accepted

Checkout inotify. If your running a recent kernel it will be included. There are numerous APIs for numerous languages out there for it.

share|improve this answer
    
I just want to run a Perl script when a file gets added to folder. Is this difficult to implement with inotify? –  user15336 Aug 2 '09 at 22:58
    
IT shouldn't be (I've never done it in Perl though), there are some modules in CPAN (search.cpan.org/search?query=inotify&mode=all) that will help take the pain out of the process. –  David Aug 3 '09 at 23:44
add comment

Ionotify, as David says, is what you're looking for. Iowatch is a little Perl script that uses Ionotify, via Perl, to report changes to a filesystem. Assuming you've got a degree of Perl scripting experience you should be able to hack this into something that does what you want.

share|improve this answer
add comment

You need a File Alteration Monitor. Take a look on http://oss.sgi.com/projects/fam/

share|improve this answer
add comment

If you need a simple frontend to FAMs, fileschanged can be useful, at least for prototyping.

share|improve this answer
add comment

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.