Created
October 19, 2022 14:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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