aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvg <vg@devys.org>2018-01-14 11:13:57 +0100
committervg <vg@devys.org>2018-01-14 11:13:57 +0100
commitdadd116a7ebcc5090be76086ad386a0b0f88460a (patch)
tree0f4764605f9c0e6ea1f81937a21357dcecd815c2
parentf5bba3428170f2e992f5d79fa88ff92f8698c885 (diff)
downloadscripts-dadd116a7ebcc5090be76086ad386a0b0f88460a.tar.gz
scripts-dadd116a7ebcc5090be76086ad386a0b0f88460a.tar.bz2
scripts-dadd116a7ebcc5090be76086ad386a0b0f88460a.zip
use temporary file list to free reduce memory usage in time
-rwxr-xr-xscripts/files_integrity_croncheck.sh9
1 files changed, 8 insertions, 1 deletions
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 \