# To future generations: this script was a lot simpler
# to implement and test than a logrotate setup.
+# Specifically, the hurdle is that logratate is designed
+# to handle multiple log files in the last path component
+# (e.g. /my/path/to/logfiles/*). KCLS log directory tree
+# has several levels which are year, month and day. To
+# fully express what this script does a lot of hardcoded
+# configuration would need to be written.
+# While it still technically should be possible to
+# configure logrotate to do what this script achieves
+# it will be really cumbersome and significantly time
+# demanding. Especially, when the log directory tree
+# structure needs to be modified in the future as it will
+# necessitate revision of logrotate configuration that
+# would need to be rewritten to account for the changes
+# in the structure of the log directory tree. Not to mention
+# use of underdocumented features (iliv@commandprompt.com)
+
# *_AGE values are stored as days
# Example: a compress value of "3" means compress files
# last modified more than 3 days ago.
# Delete all Evergreen log files that are older than DELETE_AGE
# days, except for the Apache access log and Evergreen activity log.
-/usr/bin/find /var/log/evergreen -type f -ctime +$DELETE_AGE \
+/usr/bin/find /var/log/evergreen -type f -mtime +$DELETE_AGE \
-not -name "ap_access*" -not -name "activity*" -delete
# Compress Evergreen log files older than COMPRESS_AGE days
-/usr/bin/find /var/log/evergreen/ -type f -ctime +$COMPRESS_AGE \
+/usr/bin/find /var/log/evergreen/ -type f -mtime +$COMPRESS_AGE \
-not -name "*bz2" -exec /bin/bzip2 {} \;
+# clean up empty directories
+
+/usr/bin/find /var/log/evergreen/ -type d -empty -exec rmdir '{}' \;
+