Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Created October 19, 2022 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyaevseev/8fed1eae99b8e10932ad4850aab24e5b to your computer and use it in GitHub Desktop.
Save ilyaevseev/8fed1eae99b8e10932ad4850aab24e5b to your computer and use it in GitHub Desktop.
Asterisk cron.weekly script for compressing old wav-files stored in /var/spool/asterisk/monitor
#!/bin/sh -e
WAV_AGE="185"
WAV_DIR="/var/spool/asterisk/monitor"
ARC_DIR="/home/asterisk-archives"
if test $# = 0; then
test "$(pgrep -fc "$0")" = "1" || { echo "${0##*/} is already running, exit."; exit 1; }
cd "$WAV_DIR"
nice ionice -c3 find . -type f -mtime +"$WAV_AGE" -name "*.wav" -exec "$0" '{}' +
exit $?
fi
for a in "$@"; do
DAY="${a%-??-??-??-*}"
MON="${a%-??-??-??-??-*}"
DIR="$ARC_DIR/$MON/$DAY"
#echo "destdir = $DIR"
mkdir -pm700 "$DIR"
xz -T0 "$a"
mv "$a.xz" "$DIR/"
done
## END ##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment