incron does not respond to writing new files in a new folder. how do I fix it?

458 Views Asked by At

I want to track file changes (writing) in a folder. I made this parameter

/root/var/ IN_CLOSE_WRITE curl "https://api.telegram.org/......."

And if I load a file into the var folder, curl will work, but if I create a new folder at the beginning and load a file there, nothing will happen. How can this be fixed?

1

There are 1 best solutions below

0
On

How can this be fixed?

As there's no simple fix, the apparently only choice is to append new lines to the incrontab for new folders; for this purpose, the create event has to be monitored and handled.

/root/var   IN_CLOSE_WRITE,IN_CREATE    case $% in IN_CREATE,IN_ISDIR) (incrontab -l; echo $@/$# IN_CLOSE_WRITE 'curl "https://api.telegram.org/......."') | incrontab -;; IN_CLOSE_WRITE) curl "https://api.telegram.org/.......";; esac

Note that due to this issue with incron, folder names with spaces may not work.