Questions tagged [logrotate]

logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.

logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.

Normally, logrotate is run as a daily cron job. It will not modify a log multiple times in one day unless the criterium 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.

Any number of config files may be given on the command line. Later con- fig files may override the options given in earlier files, so the order in which the logrotate config files are listed in is important. Nor- mally, a single config file which includes any other config files which are needed should be used. See below for more information on how to use the include directive to accomplish this. If a directory is given on the command line, every file in that directory is used as a config file.

If no command line arguments are given, logrotate will print version and copyright information, along with a short usage summary. If any errors occur while rotating logs, logrotate will exit with non-zero status.

AUTHORS

   Erik Troan 
   Preston Brown 
442 questions
59
votes
4 answers

logrotate daily and size?

If a logrotate config is specified with "size" and "daily" parameters, which one takes precedence? Where is this documented? I would like these rotations to occur as a boolean OR operation, ie, if the logs are a day old they get rotated, OR if they…
cat pants
  • 2,293
52
votes
6 answers

Where does logrotate save its own log?

I have logrotate running in an EC2 AWS machine rotating Apache logs. Once packed, Apache logs are saved into AWS S3 via s3fs. The problem is that I recently noticed that I didn't have logs rotated. In S3 I have old logs from day 48->60 but the 1->47…
enedebe
  • 1,086
52
votes
4 answers

When to use delaycompress option in logrotate?

The man page of logrotate says that: It can be used when some program cannot be told to close its logfile and thus might continue writing to the previous log file for some time. I'm confused by this. If a program cannot be told to close its…
36
votes
6 answers

logrotate not rotating the logs

I have this logrotate config and I am running on Ubuntu 10.04. /var/log/mysql/mysql-slow.log { daily rotate 3 compress notifempty missingok create 660 mysql adm postrotate if test -x /usr/bin/mysqladmin && \ …
Carmen
  • 817
20
votes
5 answers

Logrotate not working

I am trying to get logrotate to work on my VPS to rotate my apache files weekly. Currently the contents of the apache2 config file is as such. "/var/www/user/site.com/logs/*.log" { weekly missingok rotate 8 …
Malachi
  • 441
16
votes
2 answers

Logrotate: how to access the output file in postrotate

I rotate Nginx logs daily (with dateext). After the rotation I want to parse the file for the day that just passed and compile an email with the number of errors returned by Nginx server. How can I access the output file in the postrotate /…
ibz
  • 345
12
votes
3 answers

How to stop logrotate from changing the rotated logs owner

I have a logfile owner by the 'apache' user that I would like to rotate with logrotate. I would like to do that by running logrotate as a different user, say 'web' using the copytruncate strategy. That fails with this error: error: error setting…
Leven
  • 221
8
votes
3 answers

How can I specify multiple rules for a particular log file(s) with logrotate?

I have a logrotate.d config file that looks something like this: /home/myapp/log/* { daily compress dateext ifempty delaycompress olddir /home/myapp/baklog } There are a few particular log files where I want to apply…
Ether
  • 322
6
votes
1 answer

Using logrotate to only compress and delete old files without rotating

I want to compress some log files which have name format as abc.log.yyyy-MM-dd and then delete the compressed log file (abc.log.yyyy-MM-dd.gz) after x days.I don't want logrotate to rotate files(i.e. create new files), I only want it to compress and…
6
votes
2 answers

Logrotate not rotating

I have set new conf for logrotate, but I just couldn't get it working. Here's my logrotate: /home/deployer/abc/shared/log/*.log { daily missingok rotate 30 compress delaycompress size 5M copytruncate } Here's what I have…
Victor
  • 261
  • 1
  • 2
  • 10
4
votes
2 answers

Why auth.log gets rotated multiple times every day?

I noticed a suspicious behaviour of my auth.log. For some reason it is getting rotated multiple times everytime it should rotate. 2014-06-15 06:25:06,102 fail2ban.filter : INFO Log rotation detected for /var/log/auth.log 2014-06-15 06:25:06,102…
Möhre
  • 229
4
votes
1 answer

can logrotate process all *.log in a directory tree?

Logrotate can work on individual files or wildcarded files (*.log, for example) in a specified directory, but does it inherently have the ability to traverse a directory tree of arbitrary depth and process files it finds? thanx
user52874
  • 829
3
votes
2 answers

How does logrotate deal with copytruncate?

I understand that copytruncate is not an ideal setup, but that's the cards I'm dealt with... I have a service that is tailing data from journalctl and streaming it to a file. The setup to rotate the file is... /var/log/xxxxxx/xxxxxx.log { size…
3
votes
1 answer

Using logrotate to ONLY delete logs that are managed/rotated by another service

There are many programs out there that manage log file rotation by themselves. Many of them however only rotate the log and never delete them, and assume that is just part of the sysadmin's job and he/she will backup or delete as necessary. My…
3
votes
1 answer

logrotate compress files as a different user than specified

Using the following logrotate config file, rotated files are being chowned to the specified user but not compressed ones. /var/log/file.log { notifempty missingok size 1M rotate 30 …
pl1nk
  • 461
1
2 3 4