Questions tagged [inotifywait]

inotifywait efficiently waits for changes to files using Linux's inotify(7) interface. It is suitable for waiting for changes to files from shell scripts.

Name

inotifywait - wait for changes to files using inotify

Synopsis

inotifywait [-hcmrq] [-e <event> ] [-t <seconds> ] [--format <fmt> ] [--timefmt <fmt> ] <file> [ ... ]

Description

inotifywait efficiently waits for changes to files using Linux's inotify(7) interface. It is suitable for waiting for changes to files from shell scripts. It can either exit once an event occurs, or continually execute and output events as they occur.

126 questions
3
votes
0 answers

Batch processing files in a watched directory tree (inotifywait) with a delay

There's a directory tree which is watched by inotifywait. What I want to do is trigger a script (e.g. with which I can move the files from it) with a delay (e.g. 10sec), so this script won't be triggered at any event but in a "groupped" event. The…
Krisztian
  • 383
  • 3
  • 9
3
votes
1 answer

inotifywait not detected in /sys/class/gpio/gpioXX/ (raspberry pi)

I have connected 2 raspberry pi using GPIO : The first one is the master, and use GPIO2 (and GND...) The second one is a slave, and use GPIO0 and GPIO1 All are switch on a relay card I put GPIO1 and GPIO0 on direction "IN" and GPI02 on direction…
gamerounet
  • 279
  • 4
  • 22
3
votes
1 answer

Monitor directory and change ownership of files upon creation

I have tried this method but it does not work... inotifywait -mr -e create /opt/freeswitch/storage/ 2>&-| sed 's/ CREATE //g' | while read file; do chown apache.apache $file done From command line inotifywait -mr -e create…
Arringar1
  • 395
  • 4
  • 9
  • 21
2
votes
1 answer

Can inotifywait say a file is closed before it is accessible to another process?

I have a system where one bash script is creating zip files in a given directory every few seconds. I have another bash script which is using inotifywait to check for these .zip files appearing, and uploads them to an Amazon S3 bucket using wget.…
pmacfarlane
  • 3,057
  • 1
  • 7
  • 24
2
votes
1 answer

Are delete events considered close_write in inotifywait?

I have a simple inotifywait script that watches for FTP file uploads to be closed and then moving them to a aws s3. It seems to be working except that in the inotify logs, it indicates that the file was not found ( although the file was indeed…
ninsonTan
  • 361
  • 1
  • 2
  • 17
2
votes
1 answer

Systemd service is inactive (dead), but only after many weeks

I have a custom systemd service that scans the filesystem with inotify and creates files upon certain events. The service works fine for many days, sometimes even for several weeks. Then suddenly it is stopped. It is configured to use…
ThiagoAlves
  • 1,313
  • 16
  • 25
2
votes
3 answers

Monitor Pre-existing and new files in a directory with bash

I have a script using inotify-tool. This script notifies when a new file arrives in a folder. It performs some work with the file, and when done it moves the file to another folder. (it looks something along these line): inotifywait -m -e modify…
user10639761
2
votes
2 answers

inotify: Watch files changes except for files in .gitignore?

I'm trying to listen file changes in a folder except .gitignore to trigger rebuild. It seems like using inotifywait with --exclude option is the right way to do. Does anyone know a good way to convert .gitignore to regex such that inotifywait…
Kibeom Kim
  • 471
  • 1
  • 5
  • 12
2
votes
1 answer

Capture output of inotifywait in bash

How can i capture the output of inotifywait in this instance, it is driving me crazy. Here is my code: while inotifywait -q -e create,delete --format '%T %:e "%f"' --timefmt '%d/%m/%y %H:%M' "$DIR" do echo -e "$line" >>…
Ossama
  • 2,401
  • 7
  • 46
  • 83
2
votes
0 answers

How to read user input while in a inotifywait while loop

When I use inotifywait and then read within the while loop something breaks. I never receive the input the the script just breaks. This is an example: #!/bin/bash scriptDir=$(pwd) get_input() { read userInput echo $userInput…
ivan
  • 307
  • 3
  • 12
2
votes
1 answer

Using inotifywait (or alternative) to wait for rsync transfer to complete before running script?

I would like to setup inotifywait so that it monitors a folder and when something is copied to this folder (lsyncd which uses rsync) I would like inotifywait to sit tight and wait until rsync is done before calling a script to process the new…
Luma
  • 123
  • 5
2
votes
3 answers

inotifywait running daemon mode giving error Couldn't initialize inotify

I am running inotifywait (inotify-tools-3.14-1) in the daemon mode, however, it gave the following error and no watches are established. Also, since it is within the while loop, there were many inotifywait daemon processes created. I have no such…
jlp
  • 1,656
  • 6
  • 33
  • 48
2
votes
1 answer

Python, subprocess, pipe and select

I have a python program where I continuously read the output of other program launched via subprocess.Popen and connected via subprocess.PIPE The problem I am facing is that it sometime lost significantly portion of the output from the launched…
shodanshok
  • 167
  • 11
2
votes
1 answer

Send E-Mail on File Change in monitored directory

I want to send an e-mail notification to guys in our company if a file changed in their staff folder on the server. I have a script that works fine on sending an e-mail on every file change using inotifywait. What I would like to do is on multiple…
mrchrister
  • 49
  • 5
2
votes
2 answers

Using inotify in a script to monitor a directory

I have written a bash script to monitor a particular directory "/root/secondfolder/" the script is as follows: #!/bin/sh while inotifywait -mr -e close_write "/root/secondfolder/" do echo "close_write" done When I create a file called…
mib1413456
  • 337
  • 1
  • 3
  • 16
1
2
3
8 9