Hello Everyone,
In hybris, we have the tomcat folder, where we can find the console and access logs. So on a daily basis, the logs got generated. sometimes, which will be in GBs. which slows our system and raises memory issues. To avoid this type of issue, am writing this blog.
Hope this blog will be helpful to the people who want to delete the console/access logs automatically in a single node server. Instead of deleting them manually every time.
To achieve this, I have gone through several referral links and scripts, but they won't give a complete solution. So, I myself wrote a simple program (cronjob) that deletes the logs based on the given time interval.
Below is the simple cronjob that you need to define in your respective spring.xml file and provide the time interval in the job and start the cronjob once.
class defining in spring.xml file should be like below:
<bean id="deleteTomcatConsoleLogsCronJob" class="com.test.DeleteTomcatConsoleLogsCronJob" autowire="byName" parent="abstractJobPerformable"/>
And the java class(cronjob) is below:
Finally, Go to the backoffice once and run the cronjob. You will find the logs got deleted from the path which you have provided based on the time interval.
Thank you.