Watch Filesystem recursively and execute script when file is added in Ubuntu?

7,379

I think your solution is inotifywait:

-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 traversed. Newly created subdirectories will also be watched.

Share:
7,379

Related videos on Youtube

Evils
Author by

Evils

Work in progress...

Updated on September 18, 2022

Comments

  • Evils
    Evils over 1 year

    this problem is really driving me crazy.

    My situation is that I'm having a big directory on my ubuntu server with about 150 subfolders I need to watch. Those subfolders mainly contain PDF files where users can upload new files on their own. Now as I need to make thumbnails of those PDFs and as I cannot access the source of the tool used to upload the files, I would like to check for newly added files (at best in real time) and if a new file is added I would like to use my script to automatically use ghostscript to create my thumbnails.

    I already tried a solution with incron and another one with watcher (which didn't work at all, due to Ubuntu 10.04). Incron would have been great but doesn't work unfortunately as it can't be used for monitoring filesystems recursively...

    I would be thankful for any help/hint

  • hek2mgl
    hek2mgl about 10 years
    And how is that related to incron ?
  • uzsolt
    uzsolt about 10 years
    @hek2mgl I've answered to his question: "Watch Filesystem recursively and execute script when file is added in Ubuntu?". He wants a solution to watch his filesystem. He only wrote that incron doesn't support recursive watch. I said that inotifywait supports. So I don't understand your question.
  • hek2mgl
    hek2mgl about 10 years
    The question was imported from stackoverflow and edited during this. Originally it was more incron related. I was interested if it is really not possible with incron.
  • uzsolt
    uzsolt about 10 years
    I don't use incron but as I see in google: incron doesn't support recursive watch. But I found this: github.com/nguyent/incron-recursive