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?

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

4 Answers

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.

link|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
feedback

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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