I want to perform logrote on CentOS7, but the execution result is blurred and I do not know what to believe.

/etc/logrotate.d/testThe contents are as follows.

/var/log/test/test.log {
  create 0644 username group name
  rotate 3
  maxsize 10M
  su username group name

There are multiple commands for running logrote.

  1. /etc/cron.daily/logrotate
  2. logrotate /etc/logrotate.conf
  3. logrotate /etc/logrotate.d/test

When I run it, 1 and 2 give the same result, only 3 is different.

1 and 2 are output in this form->test.log-20201118.gz
3 outputs in this form->test.log.1.gz

Why is it different?
I expected it to be output in the form of 3, but I'm not sure that the date suddenly appears when I execute it in the form of 1 or 2.

  • Answer # 1

    Since 2 and 3 specify different configuration files, the result will be different.
    I think 1 is written as 2.

    /etc/logrotate.confThen/etc/logrotate.d/Since the following files are included,/etc/logrotate.confIf you specify, those specifications are also valid.

  • Answer # 2

    The execution result of logrotate is blurred

    Intentionally, not blurry/etc/logrotate.confBecause it is executed so as to ignore the setting of
    If you dare to do it individually/etc/logrotate.confCheck the contents and make the necessary settings/ testLet's copy to