forked from wangxiaoying/chdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatch_script.sh
More file actions
23 lines (18 loc) 路 804 Bytes
/
Copy pathwatch_script.sh
File metadata and controls
23 lines (18 loc) 路 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
WATCH_DIR="/app/accio"
SCRIPT_TO_RUN="/usr/local/bin/your_script_to_run.sh"
echo "Avvio del monitoraggio della directory $WATCH_DIR per nuovi file..."
# Loop infinito per monitorare continuamente la directory
while true; do
# inotifywait attende eventi di 'create' (creazione) o 'moved_to' (spostamento)
# in modo ricorsivo (-r) nella directory specificata
event=$(inotifywait -r -q -e create,moved_to --format '%w%f' "$WATCH_DIR")
# Estrai il nome del file dall'output dell'evento
new_file="$event"
echo "Nuovo file rilevato: $new_file"
# Esegui lo script desiderato, passando il nome del nuovo file come argomento
if [ -f "$new_file" ]; then
echo "Esecuzione dello script per il file: $new_file"
"$SCRIPT_TO_RUN" "$new_file"
fi
done