| Current File : /www-data/newsites/reports/monitor.sh |
#!/bin/bash
# Directory to monitor
WATCH_DIR="/www-data/newsites/adminpanel/assets/images"
# File to log changes (this will be read by your Nginx website)
LOG_FILE="/var/www/html/reports/changes.log"
# Ensure log file exists
touch "$LOG_FILE"
# Start monitoring
inotifywait -m -r -e create -e modify -e moved_to "$WATCH_DIR" --format '%w%f' | while read FILE
do
# Extract just the file or directory name
NAME=$(basename "$FILE")
# Append the name to the log file
echo "$NAME" >> "$LOG_FILE"
done