You are not logged in.
I don't know if there's an easier way to explain this. I'm having issues with logrotate not catching logs with -ssl_log at the end of the name. After some testing, I'm showing that while trying to match all files that don't end with gz, the globbing will exclude files ending in log... I've been doing some testing and pulling my hair out, thinking it was the dash or the hyphen, playing in a trash directory so I don't screw anything up when I stumbled upon this:
(04:54:10 AM) me: hal_j@home ~/testdir % ll
total 0
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:31 testfile1
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile1log
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile1ssl
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:31 testfile2
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile2log
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile2ssl
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:31 testfile3
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile3log
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile3ssl
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:31 testfile4
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile4log
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile4ssl
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:31 testfile5
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile5log
-rw-r--r-- 1 hal_j hal_j 0 Oct 13 04:54 testfile5ssl
hal_j@home ~/testdir % find . -name "*[^gz]"
.
./testfile3ssl
./testfile2ssl
./testfile4ssl
./testfile2
./testfile1ssl
./testfile5ssl
./testfile1
./testfile4
./testfile5
./testfile3I realize there aren't any gz files in there, but it's been properly skipping those. My issue is that it's -also- skipping the -ssl_log files, or more accurately the *log(such as the case here) files when I see no reason that it should be. Is there some obscure(I hope) setting/option/variable that I'm missing that's changing how that globbing works that it automatically skips *log files?
Offline
Your globbing on a character group, it will match anything ending with g and/or z, just do
*gzOffline
*[^gz]*zero or more of anything followed by zero or more not in the set [gz]
Last edited by loqs (2019-10-13 10:19:08)
Offline
I knew I wasn't being clear enough. Just to reiterate, I have a directory with domlogs from Apache. they're all named for either "domain.tld" or "domain.tld-ssl_log", as they're rotated out, they'll be compressed with .gz at the end of the filename, so I don't want logrotate to work on those only the domain.tld and domain.tld-ssl_log. Hence the globbing I'm using, I want logrotate to match on any file that doesn't end with gz. It's matching on -MOST- of those, but skipping those that end in "log". My globbing doesn't have log anywhere in it. I can't figure out why it's skipping those. I only want it to skip files with gz at the end.
Offline
Okay, I see what went wrong. This rule was already in place from a coworker, and I was assuming that the globbing worked how they thought it should, where "*[!gz]" excludes anything ending in "gz", when it actually matches anything not ending in "g" -or- "z". I now have it working with:
*[!.][!g][!z]Now I feel dumb.
Offline
No, that will also not do what you want. Don't try to overthink it, just specify the criteria:
find ! -name '*.gz'EDIT: for clarity, you rule will match anything that does not have a '.' in the third to last position, not a 'g' in the second to last, and not a 'z' in the last. This is not the same as not a '.gz' in the last three positions. Specifically, all of the following (and many more) would be inappropriately excluded from the result:
Some_filename.do
Some_log.01
HouseRulez
Logs
Progs
PicturesOfFrogs
MyAccount.id
ICanHazCheeseBurgerz
SourceCode.goLast edited by Trilby (2019-10-13 12:17:12)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Find is only used here as an example of what I was seeing in the regex. I need the regex to work IN LOGROTATE for specifying all files in a directory that don't end in gz.
Offline
What about the following for matching the contents of your original post
/path/testfile?
/path/testfile?log
/path/testfile?ssl
{
}If matching using logrotates glob is not possible:
https://paperairoplane.net/posts/exclud … ng-matches
Last edited by loqs (2019-10-13 21:56:14)
Offline