Added helper scripts to safely compress logs with xz
This commit is contained in:
parent
0ca98b1ba3
commit
daf0996138
11
compress_logs.sh
Executable file
11
compress_logs.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ubat=$(jq '.u_bat*1000 | floor' < /tmp/solardata.json)
|
||||||
|
ubat_thr=27400
|
||||||
|
|
||||||
|
if [ "$ubat" -lt "$ubat_thr" ]; then
|
||||||
|
echo "Battery voltage ($ubat mV) is below threshold ($ubat_thr mV). Skipping compression."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
find -name \*.csv -mtime +3 | xargs -P3 -n1 nice -n 19 ./xz_safe.sh
|
14
xz_safe.sh
Executable file
14
xz_safe.sh
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
INPUT="$1"
|
||||||
|
OUTPUT="$INPUT.xz"
|
||||||
|
|
||||||
|
xz --keep "$INPUT"
|
||||||
|
sync
|
||||||
|
if xz -t "$OUTPUT"; then
|
||||||
|
rm "$INPUT"
|
||||||
|
else
|
||||||
|
echo "Test of '$OUTPUT' failed!"
|
||||||
|
fi
|
Loading…
Reference in a new issue