From dadd116a7ebcc5090be76086ad386a0b0f88460a Mon Sep 17 00:00:00 2001 From: vg Date: Sun, 14 Jan 2018 11:13:57 +0100 Subject: use temporary file list to free reduce memory usage in time --- scripts/files_integrity_croncheck.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/files_integrity_croncheck.sh b/scripts/files_integrity_croncheck.sh index 0cf99d8..01b4951 100755 --- a/scripts/files_integrity_croncheck.sh +++ b/scripts/files_integrity_croncheck.sh @@ -23,8 +23,15 @@ mkdir -p "$output_dir" for dir in "${dirs[@]}"; do basefn="$(printf "%s\n" "$dir" | sed 's:/:_:g;s/^_//;s/_$//')" outputfn="$output_dir/${basefn}_$(date +%F_%T).md5sum.gz" + outputlistfn="$output_dir/${basefn}.tmplist" - find "$dir"/ -type f -print0 | sort -z | xargs -0 md5sum -b \ + # store file list: it avoids having the complete list in memory for all + # the time the md5sums processes will take to complete which can be + # consequent. + ionice -c 3 nice -n 19 find "$dir"/ -type f -print0 | sort -z \ + > "$outputlistfn" + + xargs --arg-file="$outputlistfn" -0 ionice -c 3 nice -n 19 md5sum -b \ | gzip -9 > "$outputfn" diff_two_last_by_mail \ -- cgit v1.2.3