I am looking for a way to check a list of document roots of 5 domains to inotify directory watch.
For a single folder it is working like this
DIRECTORY_TO_WATCH = "/home/serveradmin/"
I have a list of folders which needs to be checked recursively for my server.
I just started learning python and have some hands on experience in C language. Just starting learning developments.
Is there anyone who can help me on this? I need to have a recursive inotify watch on 5 folders mentioned in a file named /tmp/folderlist.txt
IS there any similar code available anywhere I can refer?
install inotify-tools
:
sudo apt-get install inotify-tools
and try something like:
inotifywait = ['inotifywait',
'--recursive',
'--quiet',
'--monitor', ## '--timeout', '1',
'--event',
'CREATE',
'--format', '%f']
from subprocess import PIPE, Popen
p = Popen(inotifywait + paths, stdout=PIPE)
for line in iter(p.stdout.readline, ''):
print(line)
For macosx you can get similar results using fswatch
:
if sys.platform == 'darwin':
inotifywait = ['fswatch', '--event', 'Created']
For windows see : Is there anything like inotify on Windows?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With