Skip to content

Trying to daemonize inotifywait #5

@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions