这样设置了监视,但没有创建日志文件。这是因为 var/log 是 root 吗?
#!/bin/bash
# Ubuntu_Mate 18.04 LTS
# Does NOT work Maybe because directory is root owned ??
# Use of inotifywait to monitor files in /var/log/
#Either issue ps -ef | grep inotifywait, pick the PID (in your example presumably 7341) and then send it a signal:
#kill 7341
Monitored_Directory=/var/log/
inotifywait -m "$Monitored_Directory" --format '%w%f' -e create -e delete -e moved_to -e moved_from |
while read file; do
date +'%m/%d/%Y %I:%M:%S %p' >> /home/andy/Downloads/New_Created_Files.txt
echo New file downloaded OR created. >> /home/andy/Downloads/New_Created_Files.txt
gxmessage -fg red -font 'sans 25' -timeout 3 ' File has been created,deleted, or moved to/out of the specified directory.'
done
#killall inotifywait
# To find instances of inotify
# ps -p $(find /proc/*/fd/* -type l -lname 'anon_inode:inotify' -print 2> /dev/null | sed -e 's/^\/proc\/\([0-9]*\)\/.*/\1/')