Skip to content
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

Remove succeeded cron job #104

Closed
anrw opened this issue Dec 2, 2016 · 5 comments
Closed

Remove succeeded cron job #104

anrw opened this issue Dec 2, 2016 · 5 comments

Comments

@anrw
Copy link

anrw commented Dec 2, 2016

Hey all,
Need your advice on best practice :)

I am running cron job every minute to check if there is anything I need users to notify. If so, I send them push notifications. Everything works great, however it logs me 1440 database rows a day, which I think is not great. Is it a way to remove row immediately if cron job has finished with success?

Thank you in advance,
Andrew

@evenicoulddoit
Copy link
Contributor

Hi @anrw - I think our business want something similar. I've already got a fork of Django Cron which adds some other features and I'll probably make something for this soon if you're interested?

@anrw
Copy link
Author

anrw commented Dec 19, 2016

Thanks, @evenicoulddoit! I am definitely interested, how can I find it?

@tab-cmd
Copy link
Contributor

tab-cmd commented Jan 13, 2017

@anrw we generally felt log management should be left to the dev. However, ...

@evenicoulddoit We could be interested in implementing something that is default off, but when turned on and running crons it would check for some amount of successful or overall logs defined by the user then delete. Let me know if this is something you'd be interested in contributing to. Otherwise it will go to our wishlist for now.

@tab-cmd
Copy link
Contributor

tab-cmd commented Jan 13, 2017

something like we do with this time based deletion

def clear_old_log_entries():
"""
Removes older log entries, if the appropriate setting has been set
"""
if hasattr(settings, 'DJANGO_CRON_DELETE_LOGS_OLDER_THAN'):
delta = timedelta(days=settings.DJANGO_CRON_DELETE_LOGS_OLDER_THAN)
CronJobLog.objects.filter(end_time__lt=get_current_time() - delta).delete()`

@cveilleux
Copy link

I've shared a solution that can help with this issue in #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants