Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to watch for any input given to or any changes that made in the present content over a file, upon any modification i need to run a python program which is located in the same folder.

I tried my best to understand but i'm not able to get any good result. It would be of great help, if anyone can help me through this.

share|improve this question

You can do one of two things.

  • You can write a program that directly hooks into the inotify API and reacts to change events. This is probably the most elegant, but way outside the scope of ServerFault.
  • You can use inotifywait (part of inotify-tools) to monitor a file and fire off a script whenever something happens.

For inotifywait, you'd want to set up a shell script (in init.d, most likely) to do something along these lines:

while inotifywait -e modify /path/to/file

DON'T use the -m switch when you're calling inotifywait in a conditional like this; It will not work.

share|improve this answer
i was actually using pyinotify, but here i couldn't find the tag since i'm new not given the right fir creating the tag even, anyways i found out the solution using the event handler in pyinotify. Thanks a lot for your time :) :) – Bhuvan raj May 13 '11 at 20:27
No problem. As I said, though, most anything beyond basic bash/vb scripting is usually outside the scope of ServerFault. You may be better (more quickly/accurately) served on Python questions at our sister site – Hyppy May 13 '11 at 20:37
But sorry i cannot accept your answer since i haven't tried it out.:-/ Have a good day :) :) – Bhuvan raj May 13 '11 at 20:41

Your Answer


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.