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 
436 questions
23
votes
3 answers

Logrotate and Open Files

How does logrotate handle open files? Can logrotate rotate files that a process has open?
Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448
22
votes
4 answers

How to continue redirecting stdout to a file after logrotate moves it?

I have a simple script which outputs a bunch of logs to screen and I piped the STDOUT to a file to store the logs. Since this script is long running, I needed to rotate the log files so they are chucked into smaller more manageable ones. The problem…
Mehran
  • 519
  • 1
  • 5
  • 20
22
votes
5 answers

Logrotate: Rotating non-log files?

I have a backup script that compresses various files and directories and creates .tgz archives. Files are named, e.g. ... backup_2010-10-28.tar.gz backup_2010-10-29.tar.gz backup_2010-10-30.tar.gz backup_2010-10-31.tar.gz backup_2010-11-01.tar.gz I…
jen
  • 223
  • 1
  • 2
  • 5
20
votes
6 answers

Mongodb - proper way to rotate logs

Mongo docs say that I can: use -SIGUSR1 signal and get the old log renamed and current switched use logrotate from OS I want the OS's logrotate ability to zip old files and remove oldest, but see no way to tell mongod process to switch current log…
Andrey Regentov
  • 483
  • 1
  • 4
  • 11
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
  • 2
  • 9
  • 18
19
votes
1 answer

Linux: How to enforce specific permissions on newly created logs which are created by log rotate?

I've noticed that the mail logs which are being created in /var/log are being created and owned by root (user and group). I've written a Nagios check which monitors the log and in order to allow the Nagios user to access it, I gave the other group…
Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
18
votes
2 answers

Delete files with logrotate

Is it possible JUST to delete the log files in a directory by using logrotate w/o actually rotating them? We have an app that generates logs in the following format: app.log.DD_MM_YYYY. I am unsuccessful with logrotate having the following…
Iulian
  • 428
  • 1
  • 3
  • 8
18
votes
3 answers

How to specify exceptions from wildcard settings in a logrotate configuration file?

For my logfiles I have the problem of all but one (or a few) files use the same configuration, while the rest has another one. I tried to realize this by giving a general configuration for all files and then overwriting this configuration for the…
MRA
  • 307
  • 1
  • 2
  • 8
18
votes
5 answers

Grepping through .gz log files

Does there exist a magical shell piping which would allow easily to grep through bunch of .gz log files without needing to extract them somewhere? .gz files are Apache logs, result of log rotation. I'd like to quickly check how often certain URIs…
Mikko Ohtamaa
  • 1,374
  • 3
  • 17
  • 28
16
votes
1 answer

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

My current logrotate configuration looks like this (using logrotate 3.8.7) "/var/log/haproxy.log" { daily size 250M rotate 1 create 644 root root missingok compress notifempty copytruncate } It successfully runs once a day, but when…
Hommer Smith
  • 273
  • 1
  • 3
  • 6
16
votes
2 answers

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

I have a directory with many log files, all of which I would like to rotate daily. For organizational purposes I would like to be able to move the rotated logs into a different directory (or subdirectory) named by date, keeping the last week of…
Dave Forgac
  • 3,546
  • 7
  • 37
  • 48
16
votes
1 answer

manually rotating logfile with rsyslogd

I want to force logfile rotation using logrotate -f /var/log/syslog, but it's only return tones of: error: syslog:1 unknown option 'May' -- ignoring line error: syslog:1 unexpected text I know that on this system rsyslogd is running. How to rotate…
kbec
  • 953
  • 1
  • 9
  • 10
16
votes
4 answers

Logrotate Successful, original file goes back to original size

Has anyone had any issues with logrotate before that causes a log file to get rotated and then go back to the same size it originally was? Here's my findings: Logrotate Script: /var/log/mylogfile.log { rotate 7 daily compress …
drewrockshard
  • 1,763
  • 4
  • 20
  • 27
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
  • 4
  • 8
16
votes
3 answers

When & how does logrotate run under Ubuntu 10.04?

I am new to sysadmining and have a few questions: Where and how is the logrotate procedure initaited by the system? What time of day are my "daily" rotated logfiles being rotated? Do the prerotate commands run for each log file matched in a *.log…
OoJoo
1
2
3
29 30