1

I have following files in my someDir:

blacklistadm.out00009 blacklistadm.out00008 blacklistadm.out00007 blacklistadm.out00010 blacklistadm.out00025

I have following log rotation pattern in /etc/logrotate.d/:

someDir/blacklistadm.out*[0-9]{
    weekly
    missingok
    compress
        sharedscripts
        postrotate
                rm -f someDir/blacklistadm.out*[0-9]
        endscript
}

When the log rotation script is run, it is somehow deleting all the files in someDir. What I want is to .gz all the files and after compressing delete the original file. I don't want to delete the .gz files.

Dhruv Pandey
  • 482
  • 6
  • 18

1 Answers1

0

The files are being deleted because your globbing is being used incorrectly.

blacklistadm.out*[0-9]

literally expands to any file starting with "blacklistadm.out" followed by any sequence of 0 or more characters, ending with a single character within the defined range of 0-9.

This is globbing on to everything obviously, because all your files start with "blacklistadm.out" and end in a number, so when you run your postrotate script with an identical glob you are matching everything in that directory and deleting it.

parttimeturtle
  • 1,125
  • 7
  • 22