Sleds/utils/remove-logs.sh

47 lines
1.0 KiB
Bash

#!/bin/bash
#
# remove-logs.sh [--dry-run]
#
# Without the --all option this will remove all "old" logs:
# /sl/logs
# /sl/logs/tomcat
# /sl/van/000000/*/logs-*
#
# If --all indicated, in addition to the above:
# TODO
#
if [ "$1" = "--dry-run" ]; then
DRYRUN=1
shift;
fi
if [ "${PLATFORM}" = "" ]; then
if [ `uname` = 'Darwin' ]; then
PLATFORM=Darwin
elif [ `uname` = 'Linux' ]; then
PLATFORM=lin64
fi
fi
echo "[INFO] Set PLATFORM to: ${PLATFORM}"
TOMCAT_LOGD=/usr/local/tomcat/logs
files=(/sl/logs/*.log.* /sl/logs/*.log-* ${TOMCAT_LOGD}/catalina.*.log ${TOMCAT_LOGD}/*manager.*.log ${TOMCAT_LOGD}/localhost*.*.log ${TOMCAT_LOGD}/localhost*.*.txt ${TOMCAT_LOGD}/cgsl.log.* ${TOMCAT_LOGD}/sgsl.log.* ${TOMCAT_LOGD}/sgsl-*.log.* ${TOMCAT_LOGD}/clux.log.* /sl/van/000000/*/logs-*/*.log.*)
for i in ${files[@]}; do
if [ -f "$i" ]; then
if [ "$DRYRUN" != "1" ]; then
echo "Removing: $i"
rm -f "$i"
else
echo "Dry run: $i"
fi
else
echo "No such file matches: $i"
fi
done
exit 0