I have got application log files collecting up fast inside of a directory.
The logs contains many logs that look like this (were talking 1000s+):
the Log_NAME followed by Date and application specific nonsense.
(...)
application_log_2014-07-13_20-30-09
application_log_2014-07-20_08-30-27
(...)
Below is an excerpt of a script I use to backup excess log files before I remove all, I was wondering if anyone had any idea how I could create a script within this where I remove all scripts for last month. I think it should be possible to safely remove all the: application_log_*.... that are say older then $DT_limit I set. However I need expert opinion on this because I can not exceed the limit I set and need to be safe as folder contains other .ini and log files that must be ignored so care is needed.
##LOG FILE LOCATIONS##
##LOG FILE LOCATIONS##
##LOG FILE LOCATIONS##
export EXCESS_LOG_LOCATION="/excess_log/location"
export BACKUPDIR="/backup/log_backup"
export LOGFILE_LOCATION="/log_location"
## Date/Time variables
DT=`date '+%F:%H:%M'`
for file in `ls $EXCESS_LOG_LOCATION/application_log_*`
do
mv ${file} ${BACKUPDIR}
echo "log processed file ${file}" >> ${LOGFILE_LOCATION}
done
exit 0
I will post a script I am thinking of using as soon as I make progress but if anyone has an idea or has done this before let me know.
FYI - Ignore the Backup AND MV command functionality please this is just to help you see the logic I want to follow. and help you understand where I am trying to place the date check*.