Thursday, March 31, 2022

inotify script to add entry to log file when file is created; File Monitoring; LINUX

Shell Script: inotify_test.sh

File permissions and formatting:

  • $ chmod 777 inotify_test.sh
  • sed -i -e 's/\r$//' inotify_test.sh
  • $ nohup ./inotify_test.sh 


 inotifywait -e close_write,moved_to,create,delete -m /home/app/One |

while read  directory  events filename; do

   echo "Processing $filename file...">>inotify.txt

   echo $(date +%x_%r) >>inotify_date.txt

done

No comments: