#!/bin/bash # LGSM fn_logs function # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk # Version: 210115 # Description: Acts as a log rotater, removing old logs. local modulename="Log Manager" if [ ! -e "${consolelog}" ]; then touch "${consolelog}" fi # log manager will active if finds logs older than ${logdays} if [ $(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) -ne "0" ]; then fn_printdots "Starting" sleep 1 fn_printok "Starting" fn_scriptlog "Starting" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 echo -en "\n" if [ "${engine}" == "unreal2" ]; then find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" if [ "${engine}" == "unreal2" ]; then gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) if [ "${engine}" == "unreal2" ]; then count=$((${scriptcount} + ${consolecount} + ${gamecount})) else count=$((${scriptcount} + ${consolecount})) fi if [ "${engine}" == "unreal2" ]; then find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Removed ${count} log files" fn_scriptlog "Removed ${count} log files" sleep 1 echo -en "\n" fi