Inotify-tools is a C library and a set of command-line programs providing a simple interface to inotify.

Overview

GitHub Build Status Travis Build Status Cirrus Build Status Coverity Build Status Language Grade: C/C++ Coverage Status

inotify-tools

This is a package of some commandline utilities relating to inotify.

The general purpose of this package is to allow inotify's features to be used from within shell scripts. Read the man pages for further details.

Issues
  • Fanotify support

    Fanotify support

    • Build alternative tools fsfnotifywait and fsnotifywatch
    • The alternative tools use fanotify instead of inotify on new kernels (>=v5.9)
    • The alternative tools enable watching an entire filesystem without setting up recursive watches
    • Setting up fanotify filesystem watches require admin privileges
    opened by amir73il 61
  • Trying to daemonize inotifywait

    Trying to daemonize inotifywait

    Hi,

    First, thank you for a great set of tools. Right now, I'm using inotifywait in this format:

    !/bin/sh

    /usr/bin/inotifywait -mrq -e delete /var/www | while read file; do # log deleted file done

    I noticed that inotifywait offers the option -d that allows to daemonize it. However, when I use it, I lose completely the monitoring functionality so my while loop is useless.

    In a perfect world, inotifywait will allow me to execute an unlimited number of commands specified in a directory (i.e. /etc/inotifywait.d) where I can create many .conf files containing a structure similar to: rq /var/www attrib,delete executeprogram

    where "rq" represents a recursive action with quiet mode enabled, "/var/www" a directory watched, "attrib,delete" the inotify events and "executeprogram" a program/function to execute when the notified event occurs. Then, inotifywait could be daemonized with an init script and will automatically execute the commands found in those config files.

    Could you tell me if there is a way to actually do that now with inotifywait? Right now I use a shell wrapper as binary to execute the above tasks but I would very much like to use the daemon (-d) option available into inotifywait.

    I guess, this is more a request than an issue. Would it be possible to have an option where we can specify the program to execute while the inotify event occurs? inotifywait -dq -e modify -x "kdialog --msgbox 'Apache needs love!'" /var/log/messages

    where -x is the program to execute. Still, it would require a directory where you can insert your config files containing all your commands... so we are back to the previous requested functionality.

    Thank you for your support.

    opened by ghost 17
  • Output now shows the directory of the watched file.

    Output now shows the directory of the watched file.

    inotifywait -q /var/log/everything/current used to output /var/log/everything/current MODIFY but now outputs /var/log/everything/ MODIFY.

    From man page:

    The  event  output can be configured, but by default it consists of lines of the following form:
    
           watched_filename EVENT_NAMES event_filename
    

    Is this a bug or does the man page need to be updated to reflect new behavior?

    opened by auouymous 15
  • ./build_and_test.sh fails (Ubuntu Xenial)

    ./build_and_test.sh fails (Ubuntu Xenial)

    Hello,

    I can't seem to get the latest master to to build and test on a fresh Ubuntu Xenial docker image.

    The result of:

    ./build_and_test.sh
    

    is:

    ....
    ok 1 - Exit code 0 is returned
    ok 1 - Exit code 2 is returned
    # passed all 1 test(s)
    1..1
    # passed all 1 test(s)
    1..1
    not ok 1 - event logged
    ok 1 - Exit code 2 is returned
    ok 1 - event logged
    #
    #	    run_ &&
    #	    grep ATTRIB $logfile
    #
    # passed all 1 test(s)
    1..1
    # passed all 1 test(s)
    1..1
    # failed 1 among 1 test(s)
    1..1
    Makefile:38: recipe for target 'inotifywait-daemon-logs-chown.t' failed
    make[1]: *** [inotifywait-daemon-logs-chown.t] Error 1
    make[1]: *** Waiting for unfinished jobs....
    make[1]: Leaving directory '/inotify-tools-orig/t'
    Makefile:31: recipe for target 'test' failed
    make: *** [test] Error 2
    

    Hoping to get to the bottom of this so I can write some other tests.

    Thanks

    opened by tcf909 15
  • Can't produce NUL-delimited output

    Can't produce NUL-delimited output

    The --format and --timefmt options don't appear to interpret \0 or similar. This severely limits the usefulness of this tool in applications that require safely reading arbitrarily named files.

    opened by ormaaj 11
  • Show inode number associated with watched resource in events

    Show inode number associated with watched resource in events

    Hi, Is it possible to include inode number of watched resource in event log? So inotifywait -m output would be similar to:

    /tmp/ CREATE test 529561
    /tmp/ DELETE test 529561
    

    where 529561 is the inode number of test file. I am building database where these numbers are crucial and such feature would be really helpful. Thanks

    opened by kaprog 10
  • inotifywait examples don't work when filenames has space characters

    inotifywait examples don't work when filenames has space characters

    Hello,

    The examples should recommend best practices. However, inotifywait examples don't work when filenames has space characters. I am not sure exactly how to correct the bug. But this might work:

    inotifywait -m -r -e create --format "%e%w%f" /some/folders |
    while read output; do
      case "$output" in
        CREATE,ISDIR*)
          fullpath=${output#CREATE,ISDIR}
          echo "$0: $fullpath"
          ;;
      esac
    done
    
    waiting-input Stale 
    opened by tkittich 9
  • Missed events & delayed events

    Missed events & delayed events

    Hi, I'm using inotify-tools to watch for completed file uploads (via ftp). So, I'm using inotifywait from a shell script to pass a set of directories (around 200 directories) to be watched for event CLOSE_WRITE.

    I'm seeing many events are not being received at all. And for many files, events are received very late (2/3 hours to a day late).

    Any idea what could be wrong here?

    I'm using RHEL V6.2 with following kernel version - 2.6.32-220.23.1

    Any help here is appreciated.

    Thank you.

    Stale 
    opened by rrgokul 9
  • undefined symbol: inotifytools_filename_from_event

    undefined symbol: inotifytools_filename_from_event

    Hi guys,

    I'm trying to install inotify-tools on an ubuntu machine 20.04.

    I tried first to use install it using

    sudo apt-get install inotify-tools
    

    but I got the error:

    Couldn't initialize inotify. Are you running Linux 2.6.13 or later, and was the CONFIG_INOTIFY option enabled when your kernel was compiled? If so, something mysterious has gone wrong. Please e-mail [email protected] and mention that you saw this message.
    

    Since I couldn't find a solution to this problem, I'm trying to install it from source, version 3.22.1.0, I used the following steps:

    ./autogen.sh
    ./configure --prefix=/usr --libdir=/lib64
    make
    make check  # the test passes
    sudo make install
    

    during the last step, I got the following warnings:

    [...]
    libtool: warning: remember to run 'libtool --finish /directory/lib'
    [...]
    make[2]: Entering directory '/home/vongola/Downloads/inotify-tools-3.22.1.0/src'
     /usr/bin/mkdir -p '/usr/bin'
      /bin/bash ../libtool   --mode=install /usr/bin/install -c inotifywait inotifywatch '/usr/bin'
    libtool: warning: '../libinotifytools/src/libinotifytools.la' has not been installed in '/directory/lib'
    libtool: install: /usr/bin/install -c .libs/inotifywait /usr/bin/inotifywait
    libtool: warning: '../libinotifytools/src/libinotifytools.la' has not been installed in '/directory/lib'
    libtool: install: /usr/bin/install -c .libs/inotifywatch /usr/bin/inotifywatch
    

    so I ran the command

    libtool --finish /directory/lib
    

    But in vain, since when I run inotifywait, I got:

    inotifywait: symbol lookup error: inotifywait: undefined symbol: inotifytools_filename_from_event
    

    How can I solve this please?

    Thank you in advance!

    opened by de-gozaru 8
  • Extract stats into their own file

    Extract stats into their own file

    Hi,

    we've extracted some parts concerning the file access event stats into their own file during the course of a scientific study. We want to check with whether this extraction seems sensible for you.

    opened by TorunR 8
  • Static only build fails && cross-compilation fails

    Static only build fails && cross-compilation fails

    inotify-tools-3.13

    I did the following for a cross-compilation where CONFIGURE_FLAGS holds hosts, sysroot, and other flags..

    ./configure $CONFIGURE_FLAGS --prefix=${INSTALLDIR} --enable-static --disable-maintainer-mode --disable-shared

    The goal of this configure is to avoid dynamic libraries which allows the installation of just one executeable without any special dependencies.

    After bypassing a limitation with cross compiling in the configure file, the build failed due to symbols being present in multiple locations. Information is provided below.

    Changes to configure to bypass the check - I do not think that this check should stop the compilation:

    { echo "$as_me:$LINENO: checking whether sys/inotify.h actually works" >&5
     echo $ECHO_N "checking whether sys/inotify.h actually works... $ECHO_C" >&6; }
    -if test "$cross_compiling" = yes; then
    -  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
    -See \`config.log' for more details." >&5
    -echo "$as_me: error: cannot run test program while cross compiling
    -See \`config.log' for more details." >&2;}
    -   { (exit 1); exit 1; }; }
    -else
    +if test yes = yes ; then
       cat >conftest.$ac_ext <<_ACEOF
    

    Link error (some paths changed for privacy) - multiple definition of _niceassert and isdir.

    /bin/bash ../libtool --tag=CC --mode=link arm-linux-gnueabihf-gcc -std=c99 -I../libinotifytools/src -L../libinotifytools/src -g -O2   -o inotifywait  inotifywait.o common.o ../libinotifytools/src/libinotifytools.la 
    arm-linux-gnueabihf-gcc -std=c99 -I../libinotifytools/src -g -O2 -o inotifywait inotifywait.o common.o  -L..../3rdparty/inotify-tools-3.13/libinotifytools/src ../libinotifytools/src/.libs/libinotifytools.a  
    ../libinotifytools/src/.libs/libinotifytools.a(inotifytools.o): In function `_niceassert':
    ...../3rdparty/inotify-tools-3.13/libinotifytools/src/inotifytools.c:197: multiple definition of `_niceassert'
    common.o:...../3rdparty/inotify-tools-3.13/src/common.c:112: first defined here
    ../libinotifytools/src/.libs/libinotifytools.a(inotifytools.o): In function `isdir':
    ..../3rdparty/inotify-tools-3.13/libinotifytools/src/inotifytools.c:1595: multiple definition of `isdir'
    common.o:...../3rdparty/inotify-tools-3.13/src/common.c:44: first defined here
    
    opened by mdeweerd 8
  • How can inotify-tools monitor the file operations of non-local users?

    How can inotify-tools monitor the file operations of non-local users?

    Hi, I tried to write a bash script to monitor the file changes in the smb network disk mounted on the server. Then, I found a problem. When I use the server to operate on the files, inotifywait can output the log information normally. However, if I use other hosts mounted on the same network disk to operate on the files on the disk, inotifywait seems to be unresponsive. Does this mean that inotifywait only reads the logs of file system operations on the local machine? Is there a way around this problem? Or is there another tool that can do this kind of monitoring? Thank you very much!

    opened by zaynechu 0
  • Unable to listen for mariadb database file changes

    Unable to listen for mariadb database file changes

    students.ibd is my mariadb database file

    [[email protected] students]# ll
    -rw-r--r-- 1 root    root        0 3月   8 10:25 1.txt
    -rw-rw---- 1 sac_mdb sac_mdb    65 3月   7 20:06 db.opt
    -rw-rw---- 1 sac_mdb sac_mdb  1170 3月   7 20:06 students.frm
    -rw-rw---- 1 sac_mdb sac_mdb 98304 3月   8 10:25 students.ibd
    

    Then input inotifywait command

    inotifywait -rm --timefmt "%d/%m/%y %H:%M:%S" --format '%T %e %w %f' -e "create,modify,close_write,delete,attrib,move" .
    

    Then input the following command in another shell window at this dir

    touch 2.txt
    

    inotifywait print as follow

    Setting up watches.  Beware: since -r was given, this may take a while!
    Watches established.
    08/03/22 10:30:24 CREATE ./ 2.txt
    08/03/22 10:30:24 ATTRIB ./ 2.txt
    08/03/22 10:30:24 CLOSE_WRITE,CLOSE ./ 2.txt
    

    Then i connect my db and input a insert SQL like insert students(student_name,student_address)values('jack','xxxx');

    -rw-rw---- 1 sac_mdb sac_mdb 98304 3月   8 10:31 students.ibd
    

    Database file is changed but inotifywait print nothing,how can i do? thank you!

    opened by qqliuxiaoran 5
  • mkdir -pv commands not being logged correctly

    mkdir -pv commands not being logged correctly

    I wrote a script to watch multiple directories: https://github.com/voncloft/Voncloft-Search/blob/master/voogle/new-scripts/searchengine.sh

    The script inside that script I am having an issue with is: https://github.com/voncloft/Voncloft-Search/blob/master/voogle/new-scripts/add.sh

    Whenever I execute code on my system for mkdir -pv for example

    I would like for it to execute for a/b/c ...not just the last folder

    Thanks

    mkdir -pv /temp/a/b/c (a does not exist) only "c" will be logged a and b are not put into mysql database at all.

    Am I doing something wrong?

    opened by voncloft 8
  • Add a truly quiet mode to inotifywait

    Add a truly quiet mode to inotifywait

    For my purpose use case, I only need to know when a file gets modified so I run inotifywait in a loop with what needs to be done when the monitored file gets modified. I have no use for the output line so it'd be nice if I could get rid of it altogether. I tried setting --format to an emptry string with --no-newline but inotifywait wasn't having it. Not a truly necessary feature as I can redirect the output to /dev/null but nonetheless it would make this a slightly less complex.

    opened by Ingvix 2
  • inotifywait -r doesn't react to files created in a new subdirectory

    inotifywait -r doesn't react to files created in a new subdirectory

    Hi @ericcurtin,

    This bug is originally from Ubuntu and you can see it here[1].

    [1] https://bugs.launchpad.net/ubuntu/+source/inotify-tools/+bug/1274670

    I will copy some original parts of the message in LaunchPad and add new comments. From original bug:

    If I run:

    $ inotifywait -r -e close_write --format '%w%f' /tmp/

    and then do the following in /tmp:

    $ mkdir test $ touch test/test_subdir.txt $ touch test_outer_dir.txt

    then inotifywait will output:

    /tmp/test_outer_dir.txt

    i.e. it completely missed the first file, /tmp/test/test_subdir.txt.

    If I add the -m flag to inotifywait:

    $ inotifywait -r -m -e close_write --format '%w%f' /tmp/

    then it works as expected.

    I did several tests over this bug and I discovered that this issue occurs in first sequence of commands only. In next sequences, all things will work fine. So, please, reboot the system to make a new test. I did tests over Debian Bullseye 11 (this version will be released soon) and inotify-tools 3.13, 3.14 and 3.20.11.0. All tested versions produced the same results. Maybe this issue is related to #17 and #25.

    Thanks in advance.

    Regards,

    Eriberto

    opened by eribertomota 0
Releases(3.22.6.0)
Package command provide simple API to create modern command-line interface

Package command Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra Usage pack

chenen 0 Jan 16, 2022
Tools for the Gio project, most notably gogio for packaging Gio programs

Gio Tools Tools for the Gio project, most notably gogio for packaging Gio programs. Issues File bugs and TODOs through the issue tracker or send an em

Gio 3 May 11, 2022
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

null 0 Nov 22, 2021
Soren L. Hansen 1.6k Jun 30, 2022
Simple activity indicator for your command line tools.

Simple activity indicator for your command line tools.

Luca Sepe 1 Oct 22, 2021
bluemonday-cli is a simple command-line interface to bluemonday

bluemonday-cli bluemonday-cli is a simple command-line interface to bluemonday. We've configured bluemonday for ROVR's specific requirements. It reads

ROVR Labs 0 Jan 24, 2022
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Clement Sam 2k Jun 25, 2022
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Venky 0 Dec 22, 2021
A set of Go scripts to monitor YAGPDB status via the command-line.

A set of Go scripts to monitor YAGPDB status by making GET requests to the YAGPDB status endpoint.

Joe 2 Apr 20, 2022
Aces is a command line utility that lets you encode any file to a character set of your choice.

Aces Any Character Encoding Set Aces is a command line utility that lets you encode any file to a character set of your choice. For example, you could

Ishan Goel 10 Jan 2, 2022
Inspect-descriptor-set - Example protobuf descriptor set inspector CLI tool

Quick little example of parsing a protobuf descriptor file. ❯ go run main.go -f

Daniel Selans 0 Jan 25, 2022
Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go.

What is Lux? Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go. Lux provides it's users with the abilit

BanDev 41 Jun 18, 2022
Basic command line example using golang grpc client tools

This is a basic command line interface that demonstrates using the golang GRPC API. The API is reused between dishy and the wifi router, however both

null 35 Jun 18, 2022
Command-line tools for the FFS module.

Command-line tools for FFS The blobd tool defines a JSON-RPC service that implements the FFS blob store interface over various underlying key-value st

M. J. Fromberger 0 Jan 6, 2022
Command Line Interface for Terraform Enterprise/Cloud ( tecli )

In a world where everything is Terraform, teams use Terraform Cloud API to manage their workloads. TECLI increases teams productivity by facilitating such interaction and by providing easy commands that can be executed on a terminal or on CI/CD systems.

Amazon Web Services - Labs 199 Jun 27, 2022
FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

Kaleido 1 Mar 1, 2022
a command line interface to orbit.love

orbit-cli NAME: orbit-cli - a command line interface to orbit.love USAGE: orbit-cli [global options] command [command options] [arguments...]

Geoffrey Huntley 4 May 18, 2021
FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

null 34 Jun 16, 2022
Command line interface for flomo.

flomo-cli A Golang based command line interface of flomo. 中文说明 Features Type and save to flomo using command line. Editor mode supports, able to use v

Eason Yang 14 May 17, 2022