Update inotify/opt/nginx_change_monitor.sh
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Directory to monitor
|
||||
TARGET_DIR="/etc/nginx/live/"
|
||||
|
||||
# Log file for tracking changes
|
||||
LOG_FILE="/var/log/nginx_change_monitor.log"
|
||||
|
||||
# Function to check Nginx configuration and reload if valid
|
||||
reload_nginx_if_valid() {
|
||||
echo "Checking Nginx configuration..." | tee -a "$LOG_FILE"
|
||||
if nginx -t &>> "$LOG_FILE"; then
|
||||
@@ -17,7 +14,6 @@ reload_nginx_if_valid() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Monitor the directory for changes using inotifywait
|
||||
echo "Starting Nginx change monitor for directory: $TARGET_DIR" | tee -a "$LOG_FILE"
|
||||
inotifywait -m -r -e modify,create,delete --format '%w%f %e' "$TARGET_DIR" | while read FILE EVENT
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user