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 old log files #46

Open
Ridder90 opened this issue Jul 11, 2018 · 8 comments
Open

remove old log files #46

Ridder90 opened this issue Jul 11, 2018 · 8 comments

Comments

@Ridder90
Copy link

Hi there,

I really like the logging feature. But i want to be able to remove log files older then say 7 days.
I mounted the ofelia logs volume: logs/cron:/tmp/logs

Next i tried to just remove all files:

[job-exec "clean logs"]
schedule = @every 20s
container = ofelia
command = rm /tmp/logs/*

Unfortunately this fails with stdout unable to find user root: no matching entries in passwd file

I also tried to run it on the host:

[job-local "clean logs"]
schedule = @every 20s
command = rm  /home/florian/Projects/myproject/logs/cron/*

But it fails with : failed: true, skipped: false, error: exec: "rm": executable file not found in $PATH

Any suggestions?

@thatside
Copy link

Latter variant may work if the base image would be changed from scratch to something more "full".

@Ridder90
Copy link
Author

Thanks! Will try to fork this and change line 12 in the dockerfile to FROM alpine and see if running the command on the host will work.

https://github.com/mcuadros/ofelia/blob/master/Dockerfile#12

@andrewebdev
Copy link

andrewebdev commented Aug 29, 2018

Maybe add a [global] config var that specifies the maximum log age, and then ofelia cleans any logs older than the log-age variable?

I would be willing to create a PR to add this feature if there is interest? I guess it's up to @mcuadros and he's vision for what scope for this project is.

@thatside
Copy link

This seems to be more difficult solution and it adds some functions which aren't actually related to Ofelia as a cron replacement.
Personally I think that Ofelia log format should be changed to allow using logrotate in a common way.

@andrewebdev
Copy link

@thatside that's a very good point, and yes, I agree would be good if we could use logrotate to manage this.

@thatside
Copy link

Maybe the best solution would be to have 2 logging modes:

  • one with simple logging (without task output): started - success - failure
  • one with full logging (maybe adding nested folders for each task and maybe even writing all execution logs to same files - just appending new data including some metadata like execution timestamp)

@lucaswxp
Copy link

lucaswxp commented Jun 2, 2020

Any workarounds for this inside ofelia? My servers are getting full.

@taraspos
Copy link
Collaborator

taraspos commented Jun 3, 2020

Not for the moment, but I think the approach of adding job to clean up log files must work.
Similar as OP posted, something like:

[job-local "cleanup logs"]
schedule = @hourly
command =  find /tmp/ -name "*.log" -type f -mtime +7 -delete -print

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

No branches or pull requests

5 participants