Yes, you need to run logrotate
more than once a day to achieve this. This is answered in the seconds paragraph of the man page logrotate
(8):
Normally, logrotate
is run as a daily cron job. It will not modify a
log multiple times in one day unless the criterion for that log is
based on the log's size and logrotate
is being run multiple times each
day, or unless the -f
or --force
option is used.
If you would like to run logrotate
hourly instead of daily, you can move it:
mv /etc/cron.daily/logrotate /etc/cron.hourly
Since 3.8.1 there has been maxsize
. The difference between size
and maxsize
is described here:
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.
This would make both suitable for your use: size
without any interval and maxsize
if also interval is needed. However, this doesn't change the fact that by default logrotate
runs only daily. That interval is suitable for most, as in most cases it takes a lot longer than a day for a log to grow over 250M
.