logrotate:connfで言及されているサイズ2000Mは、まだ2000Mより大きいログサイズです。

logrotate:connfで言及されているサイズ2000Mは、まだ2000Mより大きいログサイズです。

私の/etc/logrotate.conf:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
        minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.

私のログを交換する必要があります/etc/logrotate.d/apc_rtbinfo.conf

/mnt/log/frengo/apc_rtbinfo.log {
daily
missingok
notifempty
size 2000M
compress
delaycompress
sharedscripts
copytruncate
rotate 3
}

logrotateの出力:

 logrotate -v /etc/logrotate.d/apc_rtbinfo.conf
reading config file /etc/logrotate.d/apc_rtbinfo.conf
reading config info for /mnt/log/frengo/apc_rtbinfo.log

Handling 1 logs

rotating pattern: /mnt/log/frengo/apc_rtbinfo.log  2097152000 bytes (3 rotations)
empty log files are not rotated, old logs are removed
considering log /mnt/log/frengo/apc_rtbinfo.log
  log does not need rotating

私の循環ログサイズ:

# du -sh /mnt/log/frengo/apc_rtbinfo.log*
0       /mnt/log/frengo/apc_rtbinfo.log
4.7G    /mnt/log/frengo/apc_rtbinfo.log.1
80M     /mnt/log/frengo/apc_rtbinfo.log.2
0       /mnt/log/frengo/apc_rtbinfo.log-20151222
679M    /mnt/log/frengo/apc_rtbinfo.log-20151225.gz
681M    /mnt/log/frengo/apc_rtbinfo.log-20151226.gz
691M    /mnt/log/frengo/apc_rtbinfo.log-20151227.gz
0       /mnt/log/frengo/apc_rtbinfo.log-20151228
70M     /mnt/log/frengo/apc_rtbinfo.log.2.gz
80M     /mnt/log/frengo/apc_rtbinfo.log.3
80M     /mnt/log/frengo/apc_rtbinfo.log.4

ログ回転出力には「ログを回転する必要はありません」と表示されますが、「サイズ2000M」に言及しました。つまり、ログファイルが2000Mを超えると、ログファイルが回転します。

ベストアンサー1

現在のログファイルサイズ(/mnt/log/frengo/apc_rtbinfo.log)は0です。したがって、回転は不要です。

以前のログファイルでは、logrotateファイルを継続的に監視せずに定期的に(毎日、iirc)実行します。実行の間にログファイルが非常に大きくなると、次の実行までこれはわかりません。

スペースが足りない場合は、gzip大容量ファイルで実行してください。

gzip /mnt/log/frengo/apc_rtbinfo.log

より小さな圧縮ファイルに置き換えられます。

sizeと条件の両方を使用しましたdaily。しかし、size時間ベースの条件は相互に排他的です。次の条件を使用する必要がありますmaxsize

maxsize size
      Log files are rotated when they grow bigger than size bytes even
      before the additionally specified time interval (daily,  weekly,
      monthly,  or yearly).  The related size option is similar except
      that it is mutually exclusive with the  time  interval  options,
      and  it  causes  log  files to be rotated without regard for the
      last rotation time.  When maxsize is used,  both  the  size  and
      timestamp of a log file are considered.

おすすめ記事