Logrotate appends "1" at the end of compressed file name

Logrotate will default to adding a number to the file. This is so that if it's used for filenames like e.g. /var/log/messages, the rotated logs will be named /var/log/messages.0 and /var/log/messages.1 etc.

Your situation is somewhat different since you already have a timestamp in the filename, so that the extension is unnecessary. Logrotate doesn't have an option to not use an extension - but there's a workaround that you might use.

The alternative to using a number sequence is to use a date/timestamp. This defaults to -%Y%m%D, e.g. -20140618. But you can configure what the string should look like - which in your case would be an empty string. You'd do this using the following configuration:

dateext          # to use dateformat string instead of sequential numbers
dateformat ''    # to use an empty string as the dateext

You are doing nothing wrong this is the default and expected behaviour. If you want a different extension e.g a date then you can specify dateext

dateext Archive old versions of log files adding a daily extension like YYYYMMDD instead of simply adding a number. The extension may be configured using the dateformat option.

From the above you can also see the defaut behaviour is expected to be simply adding a number.


You have the option rotate 30 in your configuration, which means that 30 older versions are kept before deleting. This number is how logrotate differentiate the versions. So, in effect you are doing nothing wrong and the program behaves as designed.


This is normal behaviour for logrotate as you described it.

Normally you would want to logrotate your logfiles not via script but via cronjob(s).

For gzipping the files via logrotate you could not include the date and rather let logrotate handle the dateext.

So for a "solution" to your issue you could use the logrotate options

dateext 

and skip writing the day into your filename.

This would "remove" the 1 you see in the filename.