30 votes

rsyslog with logrotate: reload rsyslog vs copytruncate

Speaking as rsyslog author, copytruncate is actually a very, very, very bad choice. It is inherently racy and using it is almost a guarantee that you will lose log data. The more frequently the file ...
Rainer Gerhards's user avatar
24 votes

Equivalent of logrotate on OSX

You can get logrotate via Homebrew. Here are my notes from setting this up. Install brew install logrotate Configure log rotation Log rotation config files are in /usr/local/etc/logrotate.d/ ...
broofa's user avatar
  • 341
23 votes

Where does logrotate save its own log?

The only thing that logrotate records normally is in cat /var/lib/logrotate/status. This is taken from https://serverfault.com/a/518134/266525
dragon788's user avatar
  • 846
15 votes
Accepted

logrotate by size - do I need to change the cron?

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 ...
Esa Jokinen's user avatar
  • 49.8k
10 votes
Accepted

Logrotate postrotate: Log file name variable empty

Think of postrotate as the script. You have to pass $1 around within it. Try /var/log/piwik/*.log { missingok postrotate /root/createStats.sh $1 > /dev/null endscript }
BMcG's user avatar
  • 116
9 votes

Where does logrotate save its own log?

Another good place to look is /var/log/messages on CentOS for errors such as this from the cron.daily /etc/cron.daily/logrotate logrotate: ALERT exited abnormally with [1] You can also run in debug ...
Tony-Caffe's user avatar
7 votes

Does fail2ban monitor rotated log files?

One can specify multiple logs in one of two ways (or a combination). You can use file globs (wildcards) to match log files to monitor (i.e.logpath = /var/log/*somefile.log) or a list of logfiles to ...
Troy Morehouse's user avatar
7 votes

Logrotate not rotating

You've specified both size and daily in your configuration for those logfiles. My understanding is that size causes any time based rotation to be ingored (see similar questions here - this one for ...
Paul Haldane's user avatar
  • 4,547
7 votes
Accepted

How logrotate behave when there is * and there is one explicit filename in log rotation in one path?

First, logrotate doesn't have an easy way to override an existing glob match of a file. Simply trying to add a more specific match later in the config will give you an error message. So in order to ...
Jenny D's user avatar
  • 28.1k
7 votes
Accepted

Does logrotate.conf override the config of the submodules?

The rules are simply evaluated as they are read, and the last setting encountered overrides previous settings. As the /etc/logrotate.conf file has the line include /etc/logrotate.d as last, the files ...
wurtel's user avatar
  • 3,924
6 votes
Accepted

Logrotate Creating Empty Rotated Files

Even i had same issues, after adding "nocreate" option issues is solved. /opt/postgres/9.1/data/pg_log/postgresql*.log { missingok compress daily rotate 7 ...
Anthony's user avatar
  • 84
6 votes

logrotate - run the postrotate after all processing

Use sharedscripts: Normally logrotate runs the postrotate script every time it rotates a log. This is also true for multiple logs that use the same configuration block. For example, a web ...
zfou's user avatar
  • 183
6 votes

rsyslog limit log size

First of all, according to the document you linked to, your syntax is wrong as the arguments to $outchannel should be given separated by commas, so something like $outchannel mail,/var/log/mail.log, ...
BeerSerc's user avatar
  • 499
6 votes
Accepted

Logrotate not rotating

Here's how I got it working: Per Paul Haldane's answer above, ensure it's either size or daily. Ensure the file in /etc/logrotate.d/abc is owned by root - sudo chown root:root /etc/logrotate.d/abc. ...
Victor's user avatar
  • 261
6 votes

How to exclude a service under /etc/logrotate.d/ to run with the main logrotate job

If you look at the manual man logrotate.conf, you can read find tabooext option which enables you to exclude some files with specific extensions. tabooext [+] list The current taboo extension ...
Khaled's user avatar
  • 36.9k
5 votes

logrotating files in a directories and its subdirectories

It's old thread, but you can do the following: /var/log/basedir/**/*.log { daily rotate 5 } These two stars will match zero or more directories. You must be careful, though, how you define ...
bat_ventzi's user avatar
5 votes

When to use delaycompress option in logrotate?

We use: daily delaycompress nodateext This creates fixed copy of the apache access_log access_log.1 so that we can then run our Stats package as a script at the end of the day. The following day ...
Edwardg's user avatar
  • 51
5 votes
Accepted

logrotate prerotate script not getting name of file to be rotated

You are not passing anything to your shell script. So $1 in your /root/filter-syslog.sh has no value and therefore nothing is printed. echo "log file subject to prerotate: $1" To make it work, you ...
Thomas's user avatar
  • 4,305
5 votes
Accepted

How to automatically change the name of a file on a daily basis

Please refer logrotate man page option "start count" start count This is the number to use as the base for rotation. For example, if you specify 0, the logs will be created with a .0 ...
asktyagi's user avatar
  • 2,934
4 votes

Cron Process Hangs Indefinitely In Logrotate

Debug your logrotate configuation by running the logrotate command manually from the command line with the --debug or --verbose option to see where and why it hangs.
Tilman Schmidt's user avatar
4 votes

Can not mail log with logrotate

Make sure you can send mail Can your system send email? You'll likely want Postfix installed and configured. Probably to relay to another host identified by relayhost in /etc/postfix/main.cf. You ...
Ryan Babchishin's user avatar
4 votes
Accepted

logrotate: What means the message "log has been already rotated"

May be logrotate will be only on the second run begin to rotate log files. Seems that if no entry for that file is in /var/lib/logrotate/logrotate.status logrotate will be not rotate the file. So the ...
Steffen's user avatar
  • 1,009
4 votes
Accepted

How to move compressed files with logrotate

Try lastaction/endscript From the man page: The lines between lastaction and endscript (both of which must appear on lines by themselves) are executed (using /bin/sh) once after all log files that ...
Bert's user avatar
  • 3,023
4 votes
Accepted

Logcheck Ignore Logrotate

I've been using logcheck+logrotate on Debian systems for 20 years, and currently use them on ~60 Debian version 8, 9, and 10 servers, and I have never seen that message from logcheck. So I did a ...
Dave Sherohman's user avatar
4 votes
Accepted

Log Rotate doesn't rotate logs

The problem is with PATH in cron session. /bin/sh: 1: logrotate: not found You can fix with full path of command: */2 * * * * root /usr/sbin/logrotate /etc/logrotate.d/rotate_tomcat >> /var/...
Marcio Conceicao's user avatar
3 votes

Configuring Logrotate for Fluentd files. Necessary?

As pointed by @kiyoto-tamura, fluentd can partition output files by day and this is the default behaviour. And, as pointed by @vaab, fluentd cannot delete old files. Hence, the obvious solution would ...
oblalex's user avatar
  • 131
3 votes

How can I rotate many log files into a different subdirectory per rotation?

You have olddir directive you can use in config file. From the documentation: olddir Logs are moved into directory for rotation. The directory must be on the same physical device as the log ...
Eugen  Bogdanovich's user avatar
3 votes

logrotate causes php5-fpm downtime

Send USR1 instead https://github.com/php/php-src/blob/b7a7b1a624c97945c0aaa49d46ae996fc0bdb6bc/sapi/fpm/fpm/fpm_events.c#L94 The source code shows this is specifially for rotating files, I know ...
exussum's user avatar
  • 539
3 votes
Accepted

Daily logrotate error creating unique temp file: Permission denied

The first thing I would do to try and debug this would be to modify the logrotate script that cron runs and have it run logrotate in verbose mode. My script has this line in /etc/cron.daily/logrotate ...
user9517's user avatar
  • 116k
3 votes
Accepted

Endless files with copytruncate option in logrotate

For anybody who stumbles on a similar issue. The problem is in this line: /home/ubuntu/.pm2/logs/* { In particular, the catch-all * should be swapped with *.log, or else, the rotated files (with ...
Andy's user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible