Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6809345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:04:31+00:00 2026-05-26T20:04:31+00:00

In the inotifywait man changes the following is stated -r, –recursive Watch all subdirectories

  • 0

In the inotifywait man changes the following is stated

-r, –recursive Watch all subdirectories of any directories passed as arguments. Watches will be set up recursively to an unlimited
depth. Symbolic links are not tra‐versed. Newly created
subdirectories will also be watched.

Warning: If you use this option while watching the root directory of
a large tree, it may take quite a while until all inotify watches
are established
, and events will not be received in this time.
Also, since one inotify watch will be established per subdirectory, it
is possible that the maximum amount
of inotify watches per user will be reached. The default maximum is 8192; it can be increased by writing to
/proc/sys/fs/inotify/max_user_watches.

I take this to mean that every time inotifywait is called, there is a delay for large directories. Therefore, constantly monitoring a large directory with monitor function like so

inotifywait -m /home/user/Documents

is more efficient than manually looping through the directory like so (from an example in the man pages)

while inotifywait /home/user/Documents; do
 #Do Something for each file change
done

as every iteration of the while loop you have to set up inotifywait again. But with the first option, I can’t execute based on the return. Ideally what I want is a callback function like so

inotifywait -m --callback ./callback.sh /home/user/Documents

so callback.sh gets called each time with the return value of inotifywait. How would I implement this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:04:32+00:00Added an answer on May 26, 2026 at 8:04 pm

    You can pipe it like:

    inotifywait -m /my/directory | while read LINE; do ./do_something.sh $LINE; done
    

    Keep in mind that you get many events for certain operations, each of which will trigger the launch of your script.

    You can also use perl or some other language to use the API directly, which gives you tons of flexibility.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use inotifywait to watch all .js files under my ~/js
Say for example you had a shell script that utilises inotifywait in the following
#!/bin/sh inotifywait -qme CREATE --format '%w%f' /tmp/watch | while read f; do ln -s
I'm trying to use inotifywait for monitoring specific folders and recompiling if needed. The
How to get the pid in tty1 of the process launched in tty2 ?
does anyone know how to lock on a function in bash script? I wanted
I have some source code on my Mac, and in order to test I'm
I am trying to get jsdoc to automatically generate when I save my javascript
I am trying to delete a created file with inotify but it doesn't work:
I have a problem with pyinotify: the methods process_*() of the ProcessEvent are not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.