
#!/bin/sh
# File	: clean_var-ocie-recording.sh
# By	: Maarten.deBoer@Atos.net, 2017-12-18
# Subject	: Script to clear (daily) /var/log/ocie/recording. Otherwise /var will fillup
#
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
LOGDIR="${HOME}/log"
LOG="${LOGDIR}/${PGM}"

VARLOGDIR="/var/log/ocie/recording"
KEEPDAYS="2"

if [ ! -d ${LOGDIR} ]; then
  echo "  Creating ${LOGDIR} ..."
  mkdir -p ${LOGDIR}
  if [ ! -d ${LOGDIR} ]; then
    echo "  NOT possible to create LOGDIR (${LOGDIR}). Exiting ..."
    exit 2
  fi
fi

echo "`date` ${PGM} v${VER} started. For VARLOGDIR=${VARLOGDIR}"|tee -a ${LOG}

cd ${VARLOGDIR}
df -h . |tee -a ${LOG}
find *.zip -mtime +${KEEPDAYS} -exec rm -f {} \; |tee -a ${LOG}
df -h . |tee -a ${LOG}
echo "`date` ${PGM} v${VER} finished."|tee -a ${LOG}

exit 0

