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

Enable extended globbing #177

Open
xpyy opened this issue Mar 1, 2018 · 6 comments
Open

Enable extended globbing #177

xpyy opened this issue Mar 1, 2018 · 6 comments
Labels

Comments

@xpyy
Copy link

xpyy commented Mar 1, 2018

My use case:
I have directory with many subdirectories with logs like this:

/data/logs/dir1/
/data/logs/dir2/
/data/logs/dir3/
...
/data/logs/dir99/

I have to rotate logs in all subdirectories 30 days except one (for example dir5) where i need 60 days. Extended globbing allow me to use something like:

/data/logs/!(dir5)/* {
	daily
	rotate 30
}

/data/logs/dir5/* {
	daily
	rotate 60
}

Without it i found only this solution:

/data/logs/![d]*)/* /data/logs/d![i]*)/* /data/logs/di![r]*)/* /data/logs/dir![5]*)/* {
	daily
	rotate 30
}

/data/logs/dir5/* {
	daily
	rotate 60
}

... which is very ugly and unintuitive

@kdudka
Copy link
Member

kdudka commented Mar 1, 2018

I believe this could be addressed by the solution proposed in #173. If it gets implemented, you should be able to write it like this:

/data/logs/*/* {
	daily
	rotate 30
	allowgloboverride
}

/data/logs/dir5/* {
	rotate 60
}

@xpyy
Copy link
Author

xpyy commented Mar 1, 2018

Yes, thats look fine too
But anyway why logrotate doesn't support extended glob?

@kdudka
Copy link
Member

kdudka commented Mar 1, 2018 via email

@LorenzoAncora
Copy link

@kdudka #5 (comment) it's a symptom of the fact that this feature is very desirable. I suggest that the best way to implement the recursive part, moreover without the need to sacrifice the backward compatibility, is to use the zsh style globbing:

  • /x/**/*.log matches /x/y/z/k.log /x/y/v.log /x/c.log ...
  • /x/**/* matches /x/y/z/k /x/y/v /x/c ...

This should make the use of logrotate much more convenient for everyone. :-)

@iliv
Copy link

iliv commented Nov 22, 2019

On Thursday, March 1, 2018 2:13:30 PM CET xpyy wrote: But anyway why logrotate doesn't support extended glob?
logrotate implements globbing using glob(3), which I am not really familiar with. So I am not sure whether it supports the syntax you ask for. Even if it did, we would need to enable it by an option to stay compatible with already released versions of logrotate.

As I mentioned in another issue, I have been looking hard to do what @xpyy did and clearly this feature is very desirable indeed. Honestly, I was surprised we ran into this seemingly basic problem with logrotate. There are also no comparable alternatives to logrotate so.. you're our last hope, Obi-Wan! 😃

@iliv
Copy link

iliv commented Nov 22, 2019

In my particular case, I haven't been able to find any sort of acceptable workaround at all.

The only option is to move log files that need to be rotated on different conditions than the rest to a separate directory. Which is impractical for many reasons.

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

No branches or pull requests

4 participants