build script is able to detect file changes
This commit is contained in:
24
build.sh
24
build.sh
@@ -3,18 +3,14 @@
|
||||
# Define the file to watch
|
||||
file_to_watch="./"
|
||||
|
||||
|
||||
## Watch for modification events on the file continuously
|
||||
#inotifywait --monitor --event modify "$file_to_watch" | tee /dev/tty
|
||||
#while read -r directory events filename; do
|
||||
# echo "The file $filename was modified."
|
||||
# # Add your desired actions here
|
||||
#done
|
||||
|
||||
#inotifywait --monitor --event modify --format '%w %e %f' "$file_to_watch"
|
||||
|
||||
|
||||
# Watch for modification events on the file continuously, with a minimum interval of 1s
|
||||
last_modified=0
|
||||
while read -r directory events filename; do
|
||||
echo "The file $filename was modified."
|
||||
# Add your desired actions here
|
||||
done < <(inotifywait --monitor --event modify "$file_to_watch")
|
||||
current_time=$(date +%s) # Get the current time in seconds
|
||||
|
||||
if [ "$current_time" -gt "$last_modified" ]; then
|
||||
last_modified=$current_time
|
||||
echo "$current_time - The file $filename was modified."
|
||||
fi
|
||||
done < <(inotifywait -q --monitor --event modify "$file_to_watch")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user