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

222 Views Asked by At

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.

2

There are 2 best solutions below

1
Andrew On BEST ANSWER

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?

0
Walter A On

Check the full names of the files and do something like

ln -s /dev/null .err
ln -s /dev/null .out
echo "Warning: .err and .out are symlinks from /dev/null" > README