Questions tagged [inotify]

inotify is a Linux kernel subsystem that informs processes when files are accessed/created/modified or deleted.

The primary purpose of inotify is to prevent processes from regularly scanning file systems for changes which may be costly and have undesirable lags.

There is a command line interface and bindings exist for several languages including python, java, ruby, haskell, PHP.

To debug inotify related issues, you can log the actual events triggered by the inotifywatch tool. (part of the inotify-tools.)

580 questions
857
votes
20 answers

How to retrieve a module's path?

I want to detect whether module has changed. Now, using inotify is simple, you just need to know the directory you want to get notifications from. How do I retrieve a module's path in python?
Cheery
  • 21,751
  • 13
  • 55
  • 80
309
votes
14 answers

Is there a command like "watch" or "inotifywait" on the Mac?

I want to watch a folder on my Mac (Snow Leopard) and then execute a script (giving it the filename of what was just moved into a folder (as a parameter... x.sh "filename")). I have a script all written up in bash (x.sh) that will move some files…
Mint
  • 12,683
  • 29
  • 67
  • 107
103
votes
8 answers

Is there anything like inotify on Windows?

With the Linux OS, there is the ionotify subsystem which notifies an application of changes to the filesystem. However, I am mainly a Windows user, so I was wondering if there is a similar way to monitor filesystem changes?
johansson
  • 1,307
  • 2
  • 9
  • 9
78
votes
9 answers

How to monitor a complete directory tree for changes in Linux?

How can I monitor a whole directory tree for changes in Linux (ext3 file system)? Currently the directory contains about half a million files in about 3,000 subdirectories, organized in three directory levels. Those are mostly small files (< 1kb,…
Udo G
  • 11,022
  • 11
  • 47
  • 77
71
votes
11 answers

How to run a shell script when a file or directory changes?

I want to run a shell script when a specific file or directory changes. How can I easily do that?
Drew LeSueur
  • 16,653
  • 27
  • 85
  • 96
60
votes
5 answers

inotify with NFS

I've recently created a dropbox system using inotify, watching for files created in a particular directory. The directory I'm watching is mounted from an NFS server, and inotify is behaving differently than I'd expect. Consider the following…
ajwood
  • 15,375
  • 15
  • 54
  • 90
55
votes
7 answers

How do I find out what inotify watches have been registered?

I have my inotify watch limit set to 1024 (I think the default is 128?). Despite that, yeoman, Guard and Dropbox constantly fail, and tell me to up my inotify limit. Before doing so, I'd like to know what's consuming all my watches (I have very…
frio
  • 1,008
  • 1
  • 9
  • 13
52
votes
6 answers

What is a reasonable amount of inotify watches with Linux?

I am working on a daemon that monitors file events via inotify to trigger various types of events when files are accessed. I have read that watches are a little expensive, because the Kernel is storing the full path name of every file being…
Tim Post
  • 32,014
  • 15
  • 104
  • 162
38
votes
4 answers

What is the proper way to use inotify?

I want to use the inotify mechanism on Linux. I want my application to know when a file aaa was changed. Can you please provide me with a sample how to do that?
dubila
  • 819
  • 2
  • 8
  • 11
29
votes
3 answers

inotify and bash

I am trying to make a bash script with inotify-tools that will monitor a directory and alter all new files by removing lines containing "EE". Once altered it will move the files to another directory #!/bin/sh while inotifywait -e create…
user963091
  • 347
  • 1
  • 3
  • 8
27
votes
1 answer

Difference between inotify and epoll

I would like to know what the difference is between both i/o watchers inotify and epoll? inotify inotify_init(void) creates inotify instance to read events from inotify_add_watch(int fd, const char * path, int mask) returns a watch fd around the…
bodokaiser
  • 13,492
  • 20
  • 90
  • 133
24
votes
3 answers

Best way to monitor file system changes in linux

I'm looking at building a file system sync utility that monitors file system activity, but it appears that some of the file system monitoring features in the linux kernel are obsolete or not fully featured. What my research as found dnotify came…
ReDucTor
  • 313
  • 1
  • 2
  • 11
21
votes
3 answers

How do I program for Linux's new `fanotify` file system monitoring feature?

fanotify, built on top of fsnotify, is supposed to replace inotify which replaced dnotify. Are there some good programming examples or existing utilities that use fanotify to watch for changes in a filesystem? How much detail does fanotify provide?
joeforker
  • 36,731
  • 34
  • 138
  • 231
16
votes
5 answers

Getting File Create Notifications for CIFS Mount in Linux

I have a windows share mounted via CIFS on an ubuntu server. I need to a way to know when a new file has been added to the Windows share. I tried this inotify program: http://www.thegeekstuff.com/2010/04/inotify-c-program-example/ Which works fine…
ofosho
  • 395
  • 1
  • 3
  • 15
15
votes
1 answer

Using read with inotify

I have been studying inotify call, but I still a bit flaky when it comes to the read interface. These are the most relevant resourses I could find regarding how to properly interface with inotify using…
Rafael Almeida
  • 2,179
  • 3
  • 21
  • 31
1
2 3
38 39