監控文件腳本
web
#!/bin/bash daysize=0 logfile=/home/webedit/test/status.log sizefile=/home/webedit/test/siteincsize src=/home/webedit/test inotify_home=/usr/local/inotify-tools-3.14 echo $(date+%F%n%x) >> $logfile echo -e "\n" >> $logfile if[! -e "$src"] || [! -e "${inotify_home}/bin/inotifywait"] || [! -e "/usr/bin/rsync"]; then echo "Check File and Folder" exit 9 fi ${inotify_home}/bin/inotifywait -mrq -o $logfile --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e create $src | while read line do File_name=$(awk '{print $NF}' $line) size=$(du $File_name) daysize=$(($size+$daysize)) done echo "$daysize" >> $sizefile