Sunday, June 5, 2022

[SOLVED] How to stop auto-generation of log files by cron?

Issue

I have a bot on Marathi language wikipedia. The bot runs from Wikimedi's toolforge server. I have set up a cron job which generates two files: one .err and another is .out

Following is my the content from my cron file:
0 9 * * * jsub -release buster -N KiranBOT1 kiranbot1.sh

The job runs daily. I was away for around a week, and the .err file became around 500 megabytes in size. So I deleted it, and after one run when I checked the newly generated file, it was around 8 megabytes.

It doesn't generate multiple .err files, but it keeps adding on the details in the same file, which increases the file size tremendeously. I have created that bot in such a way, that even if I stop editing Wikipedia/stop checking the bot, even then the bot would keep doing its task. In such a scenario, the .err file size would just keep on increasing. I don't want that to happen.

I can live without these .err, and .out files. Is there a way to stop generating these files?

Thanks a lot in advance,
-usernamekiran.

Edit: The file names are KiranBOT1.err, and KiranBOT1.out. I apologise, I should have mentioned this in my original question.


Solution

Original throwaway comment now posted as an answer.

The day you stop generating the logs is the day that you need them...

My suggestion would be create a dated daily pair of files (KiranBOT1_YYYYMMDD.err, and KiranBOT1_YYYYMMDD.out), and use logrotate to remove after (say) one week?



Answered By - Andrew
Answer Checked By - Marilyn (WPSolving Volunteer)