0

I have inotify on my linux server. I looked up a whole lot of posting online on how to use inotify and found a sample c code that watches a directory for file create/delete. It worked fine on both local directory and nfs direcory(which is what i really need)

Now looking at opitons on how to make this a always running process i see there are the below options at least from what i understand

  1. I guess try to run this c code with a wait and never close it?
  2. incrond - which apparently is a daemon process. I dont seem to have it on my linux server i have rhel5 so i guess i need to install it. Not very clear on how the incrond would work.
  3. inotify-tools - this sounds the easiest as it says i can just use commands in a shell script

I also have questions like what happens when the nfs mount is removed, server shuts down etc., would inotify know to pick up from where it left?!

I know this is a lot of questions but any pointers would help me a great deal. Thanks in advance. Meanwhile i will continue playing with the sameple c code.

1
  • Why do you want to use inotify(7)? What for? What is the actual use case? Please edit your question to improve it. Mar 17, 2015 at 12:16

1 Answer 1

0

I don't think that inotify(7) works reliably with network file systems (either NFS or CIFS).

It could work (on the local host) if the local host is modifying/writing some NFS mounted system.

It won't work (on the local host) if some remote client is modifying/writing some NFS mounted system (mounted by the local host).

Because the NFS protocol (at least those that I know, pre NFS4) is an RPC protocol, and there is no way for the remote NFS server (mounting that NFS system) to signal to distant clients that something is happenning.

2
  • you are right. It doesnt work when i touch a file on the nfs server. I have a reuqirement where i need to listen on a directory and whenever a new file comes i need a shell script executed that will take the name of the file and generate a reference message and send it an application whihc will then pick up the file and process it. All these directories are NFS. If inotify doesnt work, what else can i use?
    – md1980
    Mar 17, 2015 at 13:35
  • Nothing would work reliably, unless it runs on the NFS server itself. You might run on the client a find command on the mounted NFS system, but that could be slow (and won't be perfectly reliable) Mar 17, 2015 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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