Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Added 20180810 - DaiNV
- _MONITOR_FOLDER1="/mnt/user/media/music" # Using absolute path
- _MONITOR_FOLDER2="/mnt/user/media/books/audioBooks"
- _LOG_FILE="/usr/local/bin/audioArrayToSSD/logs/monitor.log"
- check_log_file() {
- max=10000
- log="$_LOG_FILE"
- #touch "$log"
- count=$(wc -l "$log" | cut -d " " -f1)
- if [ "$count" -ge "$max" ]; then
- tail -n "$max" "$log" > "$log"
- fi
- }
- monitor() {
- folder1="$1"
- folder2="$2"
- inotifywait -m --exclude "$_LOG_FILE" -r -e create,delete,delete_self,modify,moved_to --format "%w%f" "$folder1" "$folder2" |
- while read NEW_FILE; do
- now=$(date +%Y%m%d_%H%M%S)
- echo "$now: File $NEW_FILE created or changed"
- check_log_file
- ./sync_arrayAudioToSSD.sh >> ./logs/sync.log
- done
- }
- touch "$_LOG_FILE"
- monitor "$_MONITOR_FOLDER1" "$_MONITOR_FOLDER2"> "$_LOG_FILE" 2>&1 &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement