2019-01-01 17:07:29 +00:00
|
|
|
# inotifywait
|
|
|
|
|
|
|
|
> Waits for changes to one or more files.
|
2021-09-02 19:33:49 +01:00
|
|
|
> More information: <https://manned.org/inotifywait>.
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
- Watch a specific file for events, exiting after the first one:
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
`inotifywait {{path/to/file}}`
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
- Continuously watch a specific file for events without exiting:
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
`inotifywait --monitor {{path/to/file}}`
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
- Watch a directory recursively for events:
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
`inotifywait --monitor --recursive {{path/to/directory}}`
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
- Watch a directory for changes, excluding files, whose names match a regular expression:
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
`inotifywait --monitor --recursive --exclude "{{regular_expression}}" {{path/to/directory}}`
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
- Watch a file for changes, exiting when no event occurs for 30 seconds:
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
`inotifywait --monitor --timeout {{30}} {{path/to/file}}`
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
- Only watch a file for file modification events:
|
2019-01-01 17:07:29 +00:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
`inotifywait --event {{modify}} {{path/to/file}}`
|
2022-08-08 18:12:39 +01:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
- Watch a file printing only events, and no status messages:
|
|
|
|
|
|
|
|
`inotifywait --quiet {{path/to/file}}`
|
|
|
|
|
|
|
|
- Run a command when a file is accessed:
|
2022-08-08 18:12:39 +01:00
|
|
|
|
2022-08-14 04:01:42 +01:00
|
|
|
`inotifywait --event {{access}} {{path/to/file}} && {{command}}`
|