2016-02-21 00:40:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Sample script to pause or resume all grab-site processes as your free disk
|
|
|
|
# space crosses a threshold value. Modify the values below.
|
|
|
|
|
|
|
|
# Default: 80GB
|
|
|
|
LOW_DISK_KB=$((80 * 1024 * 1024))
|
|
|
|
PARTITION=/
|
|
|
|
CHECK_INTERVAL_SEC=60
|
|
|
|
|
2017-12-14 05:25:48 +00:00
|
|
|
# Track whether *we* paused the grab-sites to avoid (typically) resuming
|
|
|
|
# grab-sites that were paused by the user with e.g. ctrl-z
|
|
|
|
paused=0
|
|
|
|
|
2016-02-21 00:40:24 +00:00
|
|
|
while true; do
|
|
|
|
left=$(df "$PARTITION" | grep / | sed -r 's/ +/ /g' | cut -f 4 -d ' ')
|
2017-12-14 05:25:48 +00:00
|
|
|
if [[ $paused = 1 ]] && (( left >= $LOW_DISK_KB )); then
|
2016-02-21 00:40:24 +00:00
|
|
|
echo "Disk OK, resuming all grab-sites"
|
2017-12-14 05:25:48 +00:00
|
|
|
paused=0
|
2016-02-21 00:40:24 +00:00
|
|
|
killall -CONT grab-site
|
|
|
|
fi
|
|
|
|
if (( left < $LOW_DISK_KB )); then
|
|
|
|
echo "Disk low, pausing all grab-sites"
|
2017-12-14 05:25:48 +00:00
|
|
|
paused=1
|
2016-02-21 00:40:24 +00:00
|
|
|
killall -STOP grab-site
|
|
|
|
fi
|
2017-12-14 05:25:48 +00:00
|
|
|
echo -n ". "
|
2016-02-21 00:40:24 +00:00
|
|
|
sleep "$CHECK_INTERVAL_SEC"
|
|
|
|
done
|