Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # The folder to monitor
- FOLDER="$HOME"
- # The log file to write changes to
- LOGFILE="$HOME/folder_changes.log"
- # Start monitoring the folder
- inotifywait -m -r -e create,delete,modify,move "$FOLDER" | while read line; do
- # Get the timestamp
- timestamp=$(date +"%Y-%m-%d %H:%M:%S")
- # Write the event to the log file
- echo "$timestamp - $line" >> "$LOGFILE"
- done
- #Note that inotify can consume a lot of system resources if you're monitoring a large number of files, so it's a good idea #to use it judiciously and only when necessary.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement