Troubleshooting and Maintenanc...

Kron PAM Log Rotation and Deleting Old Logs

1min

Log rotation is the process that renames a current log file (e.g., catalina.01-01-2020.out) and sets up a new log file (e.g., catalina.out) for components. Old log files fill the disk space over time; they should be deleted at certain intervals.

To delete old log files, use the following bash script. It is recommended that this script be defined as a cronjob and run at certain intervals.

#!/bin/bash #Time threshold to delete files (days). The files older than this threshold will be deleted. threshold=90; find /u01/netright-tomcat/logs/ -type f -mtime +$threshold -exec rm {} ; find /u01/mobile-tomcat/logs/ -type f -mtime +$threshold -exec rm {} ; find /u01/nssoapp/log/ -type f -mtime +$threshold -exec rm {} ; find /u01/sql-proxy/log/ -type f -mtime +$threshold -exec rm {} ; find /u01/sftp-proxy/log/ -type f -mtime +$threshold -exec rm {} ; find /var/log/messages* -type f -mtime +$threshold -exec rm {} ;