7

Deletion of tomcat logs automatically by using cronjob in Hybris

 1 year ago
source link: https://blogs.sap.com/2022/09/22/deletion-of-tomcat-logs-automatically-by-using-cronjob-in-hybris/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
September 22, 2022 1 minute read

Deletion of tomcat logs automatically by using cronjob in Hybris

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.

1-34.png

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:

2-36.png

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK