inotifywait 4.26.0 Wait for a particular event on a file or set of files. Usage: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ ... ] Options: -h|--help Show this help text. @<file> Exclude the specified file from being watched. --exclude <pattern> Exclude all events on files matching the extended regular expression <pattern>. Only the last --exclude option will be taken into consideration. --excludei <pattern> Like --exclude but case insensitive. --include <pattern> Exclude all events on files except the ones matching the extended regular expression <pattern>. --includei <pattern> Like --include but case insensitive. -m|--monitor Keep listening for events forever or until --timeout expires. Without this option, inotifywait will exit after one event is received. -d|--daemon Same as --monitor, except run in the background logging events to a file specified by --outfile. Implies --syslog. -P|--no-dereference Do not follow symlinks. -r|--recursive Watch directories recursively. -I|--inotify Watch with inotify. -F|--fanotify Watch with fanotify. -S|--filesystem Watch entire filesystem with fanotify. -M|--mount Watch entire mount with fanotify. --fromfile <file> Read files to watch from <file> or `-' for stdin. -o|--outfile <file> Print events to <file> rather than stdout. -s|--syslog Send errors to syslog rather than stderr. -q|--quiet Print less (only print events). -qq Print nothing (not even events). --format <fmt> Print using a specified printf-like format string; read the man page for more details. --no-newline Don't print newline symbol after --format string. --timefmt <fmt> strftime-compatible format string for use with %T in --format string. -c|--csv Print events in CSV format. -t|--timeout <seconds> When listening for a single event, time out after waiting for an event for <seconds> seconds. If <seconds> is zero, inotifywait will never time out. -e|--event <event1> [ -e|--event <event2> ... ] Listen for specific event(s). If omitted, all events are listened for. Exit status: 0 - An event you asked to watch for was received. 1 - An event you did not ask to watch for was received (usually delete_self or unmount), or some error occurred. 2 - The --timeout option was given and no events occurred in the specified interval of time. Events: access file or directory contents were read modify file or directory contents were written attrib file or directory attributes changed close_write file or directory closed, after being opened in writable mode close_nowrite file or directory closed, after being opened in read-only mode close file or directory closed, regardless of read/write mode open file or directory opened moved_to file or directory moved to watched directory moved_from file or directory moved from watched directory move file or directory moved to or from watched directory move_self A watched file or directory was moved. create file or directory created within watched directory delete file or directory deleted within watched directory delete_self file or directory was deleted unmount file system containing file or directory unmounted
Options (24)
| Option | Description | Source |
|---|---|---|
--exclude pattern | Do not process any events for the subset of files whose filenames match the specified POSIX regular expression, case sensitive. | help + man |
--excludei pattern | Do not process any events for the subset of files whose filenames match the specified POSIX regular expression, case insensitive. | help + man |
--include pattern | Process events only for the subset of files whose filenames match the specified POSIX regular expression, case sensitive. | help + man |
--includei pattern | Process events only for the subset of files whose filenames match the specified POSIX regular expression, case insensitive. | help + man |
--fromfile file | Read filenames to watch or exclude from a file, one filename per line. | help + man |
-qq | Print nothing (not even events). | help |
--format fmt | Output in a user-specified format, using printf-like syntax. | help + man |
--no-newline | Don't print newline symbol after user-specified format in the --format option. | help + man |
--timefmt fmt | Set a time format string as accepted by strftime(3) for use with the %T' conversion in the --format option. | help + man |
-h, --help | Output some helpful usage information. (in the manual page but not in --help) | man |
-m, --monitor | Instead of exiting after receiving a single event, execute indefinitely. (in the manual page but not in --help) | man |
-d, --daemon | Same as --monitor, except run in the background logging events to a file that must be specified by --outfile. (in the manual page but not in --help) | man |
-o, --outfile file | Output events to <file> rather than stdout. (in the manual page but not in --help) | man |
-s, --syslog | Output errors to syslog(3) system log module rather than stderr. (in the manual page but not in --help) | man |
-P, --no-dereference | Do not follow symlinks. (in the manual page but not in --help) | man |
-r, --recursive | Watch all subdirectories of any directories passed as arguments. (in the manual page but not in --help) | man |
-q, --quiet | If specified once, the program will be less verbose. (in the manual page but not in --help) | man |
-t, --timeout seconds | Exit if an appropriate event has not occurred within <seconds> seconds. (in the manual page but not in --help) | man |
-e, --event event | Listen for specific event(s) only. (in the manual page but not in --help) | man |
-c, --csv | Output in CSV (comma-separated values) format. (in the manual page but not in --help) | man |
-I, --inotify | Watch using inotify (default for inotifywait). (in the manual page but not in --help) | man |
-F, --fanotify | Watch using fanotify (default for fsnotifywait). (in the manual page but not in --help) | man |
-S, --filesystem | Watch entire filesystem of any directories passed as arguments using fanotify. (in the manual page but not in --help) | man |
-M, --mount | Watch entire mount of any directories passed as arguments using fanotify. (in the manual page but not in --help) | man |
Exit status (3) from the manual page
0 | The program executed successfully, and an event occurred which was being listened for. |
1 | An error occurred in execution of the program, or an event occurred which was not being listened for. |
2 | The -t option was used and an event did not occur in the specified interval of time. |
Examples (4) from the manual page, untested
% inotifywait test
Running inotifywait at the command-line to wait for any file in the test' directory to be accessed.#!/bin/sh
A short shell script to efficiently wait for httpd-related log messages and do something appropriate.% inotifywait -m -r --format '%:e %f' ~/test
A custom output format is used to watch ~/test'.inotifywait -qmr -e 'moved_to,create' --format '%w%f%0' --no-newline ~/test |\
Enforce file permissions in directory ~/test'