-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Glog should delete old log files automaticly #423
Comments
I think a cron job can do it This deletes the logs produced by glog under /tmp that are last modified 7 days ago.
Then
|
But If I use docker or k8s, there is no crontab. |
@DinoStray I've written the code to automatically remove old logs, but they are not yet integrated into the original codebase. @sergiud I'm not sure when to call it. Calling it at the end of LogFileObject::FlushUnlocked() seems really unwise, since that scans for old logs too frequently. Could you please help me with this? Thank you! |
I read your code but Raspberry doesn't have real time clock so can not get correct timestamp. Please check the case |
i wrote code to limit maximum size of all files about 3M which is running on raspberry pi. |
@DinoStray I tried to implement this and it works on my linux box! 😄 (gentoo-4.19.66) But I haven't tested it on Windows, I'll do it once I have spare time. Edit: Now it works on both linux and windows. Simply add this to your project to enable log cleaner, it is disabled by default. Once enabled, it will automatically remove old logs that are last modified over 3 days. Only the logs produced by the project which glog is linked in will be removed, logs from other projects won't be touched.
You can also disable it at anytime by calling
Please see here for technical details. |
So there's no way get the timestamp for a file on Raspberry pi? I'll try to see if I there are other ways. Edit: Sorry, I mean get current time, not file's timestamp. |
@DinoStray I think you could close this now |
For example, I wanna keep log files for only 7 days.
Then the glog should delete all the log files which last modify time before 7 days.
The text was updated successfully, but these errors were encountered: