• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

inotifywait Command Examples in Linux

by admin

inotifywait is a command-line tool that uses the inotify Linux kernel subsystem to watch for changes to one or more files or directories. It can be used to monitor a file or directory for modifications, such as changes to the file’s contents or attributes, or for events such as a file being created or deleted.

When a change is detected, inotifywait will output the event and the file or directory that it occurred on to the console. The tool can also be used to execute a specific command when a change is detected.

inotifywait Command Examples

1. Watch a specific file for events, exiting after the first one:

# inotifywait /path/to/file

2. Continuously watch a specific file for events without exiting:

# inotifywait --monitor /path/to/file

3. Watch a directory recursively for events:

# inotifywait --monitor --recursive path/to/directory

4. Watch a directory for changes, excluding files, whose names match a regular expression:

# inotifywait --monitor --recursive --exclude "regular_expression" /path/to/directory

5. Watch a file for changes, exiting when no event occurs for 30 seconds:

# inotifywait --monitor --timeout 30 /path/to/file

6. Only watch a file for file modification events:

# inotifywait --event modify /path/to/file

7. Watch a file printing only events, and no status messages:

# inotifywait --quiet path/to/file

8. Run a command when a file is accessed:

# inotifywait --event access path/to/file && command

Filed Under: Linux

Some more articles you might also be interested in …

  1. pwck Command Examples in Linux
  2. check-support-status: Command Examples in Linux
  3. What is Soft Links and Hard Links in Linux File System
  4. wc: command not found
  5. flyctl: Command-line tool for flyctl.io
  6. qjoypad: command not found
  7. btrfs scrub Command Examples in Linux
  8. hexyl Command Examples
  9. hsw-cli Command Examples
  10. ledger Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright