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.)

633 questions
8
votes
0 answers

getting notified on flock/lockf/fcntl changes without polling

Is there a way (in Linux) of getting updates on the lockedness status of a file without polling? I know that the status can be polled via a lockf(fd, F_TEST) or speculative LOCK_NB|LOCK_SH, but polling is bad(tm). Of course, finding out when a file…
user2769258
  • 584
  • 3
  • 3
8
votes
1 answer

inotify FD - why is the limit per user id and not per process?

In Linux, limit on the number of inotify instances a process can have open is limited by a per user-id max number, specified in /proc/sys/fs/inotify/max_user_instances Natural thing would be to limit it per process, like file FDs for example. Since…
Manohar
  • 3,865
  • 11
  • 41
  • 56
7
votes
2 answers

How to fix "Function not implemented - Failed to initialize inotify (Errno::ENOSYS)" in rails

So I'm running the new Apple M1 Pro chipset, and the original M1 chip on another machine, and when I attempt to create new RSpec tests in ruby I get the following error. Function not implemented - Failed to initialize inotify (Errno::ENOSYS) the…
olenderpj
  • 140
  • 1
  • 9
7
votes
3 answers

Fast Haskell rebuild+test with file watch using cabal + GHCID?

my question in short is "how to get a fast save-retest workflow in a cabal-managed multi-library haskell project repository?" I already tried a few things and did some research. Before getting into more details please have a look at the typical…
tfc
  • 127
  • 9
7
votes
2 answers

inotifywait triggering event twice while converting docx to PDF

I have shell script with inotifwait set up as under: inotifywait -r -e close_write,moved_to -m "/upload" --format '%f##@@##%e##@@##%w' There are some docx files residing in watched directory and some script converts docx to PDF via below…
Jatin Dhoot
  • 4,294
  • 9
  • 39
  • 59
7
votes
1 answer

inotify C headers

So I'm trying to write a C program that uses inotify. I've used pyinotify before so I understand how it works. However, I'm following some guide and it tells me to include . The problem is that this header only has macro…
Falmarri
  • 47,727
  • 41
  • 151
  • 191
7
votes
3 answers

Is there a way to watch a mysql database for changes using perl?

I'm looking for a solution similar to the inotify method of watching files for changes. I'm aware that I could watch the binlog file of the mysql database and run queries to pick out the new results but that seems very inefficient and inelegant; as…
Drake
  • 1,938
  • 3
  • 18
  • 26
7
votes
1 answer

Why isn't Pyinotify able to watch a dir?

I would like Pyinotify to watch a templates directory, which has subfolders, but I'm getting this error: DIRECTORY /home/project/templates [Pyinotify ERROR] add_watch: cannot watch /home/project/templates WD=-1 [Pyinotify ERROR] add_watch: cannot…
Matt Norris
  • 8,596
  • 14
  • 59
  • 90
7
votes
5 answers

run inotifywait on background

I have this code copied from linuxaria.com as example and work just fine on my case the problem is when I exit from terminal inotifywait stop. I want run on back ground even after exit the terminal. how I can do that? #!/bin/sh #…
user1396982
  • 115
  • 1
  • 2
  • 9
7
votes
1 answer

Using non-blocking iNotify

My objective: To monitor a text file for modification without the monitor blocking my program, but forming part of a loop (so checking sequentially) instead. My head says: Either find a way to run iNotify in non-blocking mode, or thread iNotfiy. I…
Cornel Verster
  • 1,664
  • 3
  • 27
  • 55
7
votes
3 answers

inotify not firing notifications on file modification

I have been tweaking the example here to make it repeatedly watch a file for 'modifications'. My code is here. In my tests the inotify notification is only firing the first time the file is 'modified'(i.e. touch'ed). Any subsequent modifications to…
decimus phostle
  • 1,040
  • 2
  • 13
  • 28
6
votes
1 answer

how to automatically delete created file in linux with inotify?

I am trying to delete a created file with inotify but it doesn't work: inotifywait -r --format '%w%f' -e create /test && rm $FILE when i create a file in /test I get this: /test/somefile.txt rm: missing operand Try `rm --help' for more…
MilMike
  • 12,571
  • 15
  • 65
  • 82
6
votes
1 answer

Smooth Operator: Rename a file while writing to it

In Linux (probably also in Windows/OSX) if we open a file to write and while writing to it we rename it, the raku process goes smooth and keeps writing to the file as it should. But how can we find the new name (path) of the file while the renaming…
jakar
  • 1,701
  • 5
  • 14
6
votes
3 answers

inotifywait shell script run as daemon

I have a script that watches a directory (recursively) and performs a command when a file changes. This is working correctly when the monitoring flag is used as below: #!/bin/sh inotifywait -m -r /path/to/directory | while read path action…
Nicholas
  • 546
  • 1
  • 6
  • 19
6
votes
1 answer

How to listen only to specific events in inotifywait?

Can someone explain why inotifywait still reports about opened files, when I have excluded open? mkdir /tmp/a inotifywait --exclude acess,attrib,close_write,close_nowrite,close,open,moved_to,moved_from,move,delete,delete_self,unmount -r -m…
Jasmine Lognnes
  • 6,597
  • 9
  • 38
  • 58