Just a follow up to this for anyone else needing to rotate both logs and prune old reports. I did create a BASH script to prune the reports but they kept coming back. Long story short, you have "sort of" implemented log rotation. There are two parts to the log rotation, one is the actual "access.log" containing the raw data and one is the "reports" pages that have the HTML.
I had a cron.weekly script that pruned the older reports pages:
daysToKeep=30
minKeepEpoch=$(date --date "$daysToKeep days ago" +%s)
for dir in /opt/dnssafety-ui/var/reports/*; do
dirName=${dir##*/}
dirEpoch=$(date --date ${dirName//./} +%s)
(( dirEpoch <= minKeepEpoch )) && rm -rf $dir
done
That works for 30 days worth of reports. However! These reports will keep coming back due to the cron.daily dnssafety_report script that looks through
/opt/dnssafety/var/log/ and collects data. So I looked at writing a quick script to prune the access.log It turns out that after writing the script and putting it in
/etc/logrotate.d I didnt have to! You have already written a rotation script:
/etc/logrotate.d/dnssafety
This was set to 367 days inside the code (and there doesnt seem to be a UI link to change this), I simply needed to change the setting to 30 days. Now I have 47gb recovered in logs so this VM can carry on a little while longer.
Still, I dont think this rotation prunes the reports directory; only the access.log so I would have needed my first script anyway....