Deleting error logs
-
This problem has been mentioned many times here for years but the only suggestion is to rotate the logs, which won't help with disk space.
Rotating logs does in fact help with disk space as normally they're compressed when rotated.However, I can write a cron job in php to do what I want. My plan is to have the script cycle through all of the directories in /home/ and delete any error log files found that are above some size limit. I would only need to run the script once a week, or maybe even once a month. My question is if there is any reason why I would not want to do this?
Yea a huge one is you wouldn't necessarily want to get rid of relevant logs if there's an issue with the server, so say someone is currently having an issue on the server, and their log file is getting filled with errors constantly, or say you needed to go back and audit an issue with an account that happened say last week but you can't any longer because the logs have been removed. The solution I would suggest is rotating + compressing. Then implement the cron job or script to delete the oldest compressed log file, maybe once monthly.0 -
Rotating logs does in fact help with disk space as normally they're compressed when rotated.
Last, week, I deleted an error log file that was over 5 GB. Even if that reduced to half with compression, it is a lot of wasted space. I understand what you are saying about deleting the log and then having some problem occur, but I think that unlikely if I delete the files once a month. But if I rotate the logs and then delete the last one as you mentioned, that might be the best of both options as long as I can limit the size when rotating. I haven't tried it yet but if I can rotate at 5 MB, which is still huge for such a file, then eventually that will keep the size down, I think. I mainly just wanted to be sure that deleting files like that would not cause any server issues and it sounds like it would not from you reply. Thank you for the help.0
Please sign in to leave a comment.
Comments
2 comments