Created
April 13, 2018 17:15
-
-
Save maxclark/47521ca735d844d6dd7c88e75c1cc588 to your computer and use it in GitHub Desktop.
Simple script to rotate FreeSWITCH CDRs for our BSS platform
This file contains 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 | |
SOURCE=/var/log/freeswitch/cdr-csv | |
PICKUP=/home/cdr/cdr | |
ARCHIVE=/home/cdr/archive | |
# Instructs FreeSWITCH to rotate the CDR file | |
# | |
#/bin/kill -HUP `cat /usr/local/freeswitch/run/freeswitch.pid` | |
/usr/bin/fs_cli -x 'cdr_csv rotate' | |
# Create the directories we need if they don't exist | |
# | |
if [ ! -d "${PICKUP}" ]; then | |
mkdir -p ${PICKUP} | |
fi | |
if [ ! -d "${ARCHIVE}" ]; then | |
mkdir -p "${ARCHIVE}" | |
fi | |
# ARCHIVE everything older than x days | |
# | |
#echo "find ${SOURCE} -name 'Master.csv.*' -ctime +60 -exec mv {} ${ARCHIVE} \;" | |
find ${SOURCE} -name 'Master.csv.*' -ctime +60 -exec mv {} ${ARCHIVE} \; | |
# Sync to the $PICKUP directory for remote retrieval | |
# | |
rsync -a --delete /var/log/freeswitch/cdr-csv/Master.csv.* /home/cdr/cdr/ | |
# Make sure the files are readable | |
# | |
/bin/chmod 644 /home/cdr/cdr/Master.csv.* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment