2

I use incron for watch a direcory and run a script if a file is added.
In /etc/incron.d/ I have a file with:

/home/pat0/downloads IN_CLOSE_WRITE /var/www/owncloud/scanOC.sh pat0

It's ok when I add a file in /home/pat0/downloads but, if I create a subdirectory and I add in a file no thing run.

For exemple /home/pat0/downloads/test/myfile.txt is not seen.

How can I watch /home/pat0/download and all its future subdirectories and files?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
patol
  • 136
  • 2
  • 10
  • this should work `/home/pat0/downloads IN_CLOSE_WRITE,recursive=true /var/www/owncloud/scanOC.sh pat0` – Akhil Aug 08 '21 at 14:28

3 Answers3

3

According to the man page:

... Also, there is the symbol recursive=false. This symbol limits the observation on the specified directory and does not include subdirectories.

This rather implies that in the absence of such a flag incrond will check sub-directories. However my experience is that it does not. Sadly, specifying recursive=true also does not work.

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • specifying `recursive=true` works for me. you need to restart `incrond.service` or reload via `incrontab -d` – Akhil Aug 08 '21 at 14:25
2

No, I don't think this is possible with incron. Please check with Watcher.

Watcher is a daemon that watches specified files/folders for changes and fires commands in response to those changes. It is similar to incron, however, configuration uses a simpler to read yaml file instead of a plain text file. It's also written in Python, making it easier to hack.

Rupesh
  • 1,636
  • 13
  • 18
0

Recursive directory watching in incron is a new feature added in version 0.5.12 (see https://github.com/ar-/incron/blob/master/CHANGELOG):

0.5.12 2015-02-01

  • added recursive directory watching
  • added configuration parameters: recursive, dotdirs and loopable
  • added upstart script
  • extended manpages and readme
Community
  • 1
  • 1
El Yaz
  • 1
  • A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it is there, then quote the most relevant part of the page you are linking to in case the target page is unavailable. Answers that are little more than a link may be deleted. 1. https://meta.stackexchange.com/a/8259 2. https://stackoverflow.com/help/deleted-answers – Sagar Darekar Jun 03 '22 at 10:34