Score:0

Logrotate group of files if any member is eligible

kr flag

I have a group of log files (they are related but that's application level and not relevant). I want to set up logrotate configuration on Debian linux to rotate the whole group (all the files) once any of them reaches the limit, say 100MB for example. I can't see such an option - any idea how to achieve that?

djdomi avatar
za flag
there is and logrotatr is well documented. show us the research you have done
wick avatar
kr flag
@djdomi I have looked through the docs and I couldn't find the answer. Happy to share a photo of me reading.
Score:0
kr flag

I ended up with own script that triggers logrotate in forced mode.

Score:0
za flag

bash: man logrotate.conf

File selection

   missingok
          If the log file is missing, go on to the next one without issuing an error message.  See also nomissingok.

   nomissingok
          If a log file does not exist, issue an error.  This is the default.

   ifempty
          Rotate the log file even if it is empty, overriding the notifempty option (ifempty is the default).

   notifempty
          Do not rotate the log if it is empty (this overrides the ifempty option).

   minage count
          Do not rotate logs which are less than <count> days old.

   maxage count
          Remove rotated logs older than <count> days.  The age is only checked if the logfile is to be rotated.  rotate -1 does not hinder removal.  The files are mailed to the configured address if maillast and mail are configured.

   minsize size
          Log files are rotated when they grow bigger than size bytes, but not before the additionally specified time interval (daily, weekly, monthly, or yearly).  The related size option is similar except that it is mutually exclusive with the time  interval  options,  and  it
          causes log files to be rotated without regard for the last rotation time, if specified after the time criteria (the last specified option takes the precedence).  When minsize is used, both the size and timestamp of a log file are considered.

   maxsize size
          Log  files are rotated when they grow bigger than size bytes even before the additionally specified time interval (daily, weekly, monthly, or yearly).  The related size option is similar except that it is mutually exclusive with the time interval options, and it causes
          log files to be rotated without regard for the last rotation time, if specified after the time criteria (the last specified option takes the precedence).  When maxsize is used, both the size and timestamp of a log file are considered.

Source 1: Debian Bullseye "man" command
Source 2: https://linux.die.net/man/8/logrotate

The above, does include a Single file, while also use for a complete Sub-Directory

Full Examples

Here you decice, what, a single file, a bunch of .log or / any

/var/log/folder/*.log {
    minsize 10M
    maxsize 50M
}
/var/log/folder/single.log {
    minsize 10M
    maxsize 50M
}
/var/log/folder/* {
    minsize 10M
    maxsize 50M
}

i think that will solve all your questions.

wick avatar
kr flag
it will not? where do you see rotating groups? Every file within a group is dealt with separately. It is unlikely `logrotate` can do what I ask for.
djdomi avatar
za flag
sorry but question is unclear, you asked for limited the size, if you want to have this for the whole folder it is also possible
wick avatar
kr flag
no, I say "to rotate the whole group (all the files) once any of them reaches the limit". What in this wording makes you think of a folder? What makes you think it is possible? Please, delete your answer.
djdomi avatar
za flag
ive added the whole example - its still the same what i said
wick avatar
kr flag
I mean, I am very well familiar with logrotate. Your answers are irrelevant because what you drafted above is a standard selection. Every file is dealt with one by one. I had to use custom config and write up a script to trigger its forced mode manually to rotate all matching files as a group regardless criteria. Topic closed.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.