Docs / Linux Basics / How to Monitor File Changes with inotifywait

How to Monitor File Changes with inotifywait

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 54 views · 1 min read

Watch files and directories for changes in real-time.

Install

apt install inotify-tools -y

Watch a Directory

inotifywait -m -r /var/www/html/

Watch for Specific Events

inotifywait -m -e modify,create,delete /var/www/html/

Auto-Restart on Change

while inotifywait -r -e modify /var/www/myapp/; do\n    systemctl restart myapp\ndone

Use Cases

  • Auto-reload development servers
  • Security monitoring
  • Trigger builds on file changes

Was this article helpful?