From 50658629b18dc0d1d79fcdb3c547059c8f8acc43 Mon Sep 17 00:00:00 2001 From: paulc Date: Fri, 9 Sep 2011 16:09:57 +0000 Subject: [PATCH] Added sample custom log and CDR rotator script. git-svn-id: http://yate.null.ro/svn/yate/trunk@4593 acf43c95-373e-0410-b603-e72c3f656dc1 --- tools/log_rotate.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 tools/log_rotate.sh diff --git a/tools/log_rotate.sh b/tools/log_rotate.sh new file mode 100755 index 00000000..52ecf961 --- /dev/null +++ b/tools/log_rotate.sh @@ -0,0 +1,19 @@ +#! /bin/sh + +# Sample log and CDR rotator that creates files based on date and hour +# Assumes Yate writes to /var/log/yate and /var/log/yate-cdr.tsv + +# You can place this script in /etc/cron.hourly and not use the system logrotate +# NOTE: Files are never deleted! Periodic cleanup is required + +base="/var/log" +old="$base/yate-old" +ym=`date '+%Y-%m'` +d=`date '+%d'` +h=`date '+%H'` + +mkdir -p "$old/$ym/$d" +mv "$base/yate" "$old/$ym/yate-$d-$h.log" +mv "$base/yate-cdr.tsv" "$old/$ym/$d/yate-cdr-$h.tsv" + +/bin/kill -HUP `/bin/cat /var/run/yate.pid`