Questions tagged [inotify]

201 questions
20
votes
1 answer

How does inotify work?

According to Wikipedia, inotify is a Linux kernel subsystem which notices changes to the file system. It replaced the previous dnotify. Programs that sync files (such as crashplan, dropbox, git) recomend in user guides that the user increase…
spuder
  • 18,053
6
votes
2 answers

Will incron's IN_CREATE event give me a blank file?

I want to monitor a directory for new files, which will be created by another process. I plan to use incrod to do this. I am not interested in reacting to changes in files, as the files should never be updated. Therefore the IN_CREATE event seems…
4
votes
2 answers

How can I see how many inotify watchers a user has open?

When I run a command in a container, I'm getting inotify_init1() failed: Too many open files How can I see how many inotify watchers I have open and what's holding them open?
Evan Carroll
  • 30,763
  • 48
  • 183
  • 315
4
votes
0 answers

Alternative to inotifywait which allows easy working on *.json files only

It seems that inotifywait works with exclude lists only. I have seen the workarounds, but don't like them: How to use inotifywait to watch a directory for creation of files of a specific extension Is there a tool which allows listening for *.json…
guettli
  • 1,389
4
votes
0 answers

Share an instance of inotify between processes

I have a big folder of many (40,000+) files that are watched by at least 3 programs each one using inotify watches to detect changes (media servers, sync apps,...). Each program runs it's own instance of inotify, consuming a lot of watches, and…
3
votes
0 answers

Are inotify events guaranteed to come in the right order?

I have a single thread writing a stream of data into files in a directory. The data stream can pause for any length of time just as easily as it writes a continuous trickle of data. It writes one file at a time and whenever the file grows too…
2
votes
1 answer

inotify detect a new file write without missing write_close event

I want to watch a file created and written in a directory by a process. I don't have access to inotifywait tool, so I'm using just the inotify library calls. I start with IN_CREATE to monitor that the file was created. If the file of interest was…
rookie
  • 135
2
votes
1 answer

Notify when programs access path only via specific symlink

My HDD mountpoint was at /mnt/old, now I changed it to /mnt/new So for seamless transition now /mnt/old is a symlink to /mnt/new. Gradually I want all the programs to use the new mountpoint. How can I monitor what programs access the old path…
asd
  • 21
2
votes
2 answers

How can I terminate a process if a second inotify event occurs?

inotifywait -q -m -e close_write,create --recursive ../orgmode-parse-print | while read -r filename event; do echo $filename; echo $event sleep infinity; done The problem with the above is it 'sleeps' forever and never terminates. How…
1
vote
1 answer

incrontab reports modifying a file that doesn't exists

I have created this incrontab entry: /tmp IN_ALL_EVENTS /home/me/changes.sh $@/$# $% and this script (changes.sh): #!/bin/bash echo "file $1 changed(flgs: $2)" >> /home/me/changes.log When I use tail -f /home/me/changes.log it repeatedly prints…
John
  • 61
1
vote
1 answer

inotifywait : insert arbitrary string to output format

I want to capture inotify CLOSE_WRITE events in a directory and write CSV info to a history file. My attempt : #!/bin/bash dir=/home/stephen/temp host=$(hostname) inotifywait -e close_write -m --timefmt '%Y-%m-%d,%H:%M' --format '%T,$host,%e,%w,%f'…
Stephen Boston
  • 2,178
  • 4
  • 32
  • 55
1
vote
0 answers

inotifywait not working with Visual Studio Code

I tried to make myself a small shell script that would watch for file changes using inotifywait and copy modified/created files and delete deleted files to some destination folder (or rsync specific file). I was not able to make this work.…
gnivirht
  • 151
1
vote
2 answers

What is mean of "not explicitly being listened" on manual page of inotifywait?

man inotifywait: delete_self A watched file or directory was deleted. After this event the file or directory is no longer being watched. Note that this event can occur even if it is not explicitly being listened for. unmount The…
1
vote
1 answer

inotify not working on one specific folder

I have a problem where inotify, no matter what I do, doesn't detect changes in one specific folder. It detects changes in other folders that otherwise are no different. What could be causing this? inotifywait 3.14 Linux titan 3.16.0-4-amd64 #1 SMP…
0
votes
1 answer

Inotifywait not executing when actions to be taken are on remote server

I am trying to monitor file creation with inotifywait and execute a long script on every file creation. Everything works smoothly when the action to be taken is on the same server. But when it requires doing something on a remote server, the action…
yazzou
  • 45
1
2