Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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]
/mnt/usb/access_*.log

Which other options do I have to set?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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