I would like to delete following files with newsyslog.conf when the files are older than 6 month:

# logfile    [owner:group]    mode    count    size    when    flags    [/pid_file]

Which other options do I have to set?


You need to specify values for all of the mandatory fields.

The following will cause new log files to be created with mode 644, and will keep at most 6 files, before deleting the oldest. The * in the size field tells newsyslog not to consider the size of the file when running. $M1D0 means "rotate the file once a month, on the first day of the month, at midnight". GJN tells newsyslog that the filename is a shell pattern and that it should rotate all files that match (G), that it should compress the rotated file with bzip2 (J), and that it does not need to send a signal to a daemon process (N).

# logfile    [owner:group]  mode  count  size  when    flags
/mnt/usb/access_*.log       644   6      *     $M1D0   GJN

Without knowing more about your use case, it's impossible to give you a more specific instruction. For example, you say nothing about how these files are written, or what ownership should apply, but the newsyslog.conf manpage is pretty detailed, and should help you fill in the blanks.

  • What is the value for "when", when I want to delete the files each 6 month? – TaXXoR Jul 29 '13 at 5:47
  • 1
    In this case, 6 in the count column will cause newsyslog to delete a file once it reaches 6 months of age, based on the fact you are rotating once a month, on the first day of the month, as specified in when. count controls the number of files to keep, before deleting the oldest to make way for newer ones. – D_Bye Jul 29 '13 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.