Questions tagged [logrotate]

logrotate is a program which is scheduled (usually nightly or weekly) to archive log files by renaming them with a suffix so that the applications writing the log files start writing to new (empty) files.

Traditionally, a numbering system is used when renaming the log files: the most recent log file is renamed by having the .1 suffix appended to it, the second most recent file has .2 appended to it, etc. When the maximum number of archived log files is reached, the oldest log file (with the highest number) is deleted and the suffix of each successive log file is incremented, resulting in the “rotation” of the log files.

The archived log files can optionally be compressed to conserve disk space and some implementations of logrotate use date-based suffixes rather than numbers when renaming the log files.

272 questions
158
votes
4 answers

How to make log-rotate change take effect

I followed this link to change log-rotate configuration for RHEL 6 After I made the change to config file, what should I do to let this take effect?
BufBills
  • 3,035
  • 7
  • 22
  • 20
142
votes
1 answer

How to do a `tail -f` of log rotated files?

On a long running system I usually have a terminal with $ tail -f /var/log/kern.log or something like this open. But from time to time I have to restart such command because no new messages are displayed anymore. I assume this is because of the log…
maxschlepzig
  • 56,316
  • 50
  • 205
  • 279
68
votes
4 answers

Logrotate: "log does not need rotating" why?

I have the following new logrotate configuration: /var/log/nexus/nexus.log { rotate 7 missingok compress delaycompress copytruncate daily } When I run logrotate -d nexus, I get the following: reading config file…
Rich
  • 4,439
  • 10
  • 33
  • 34
51
votes
1 answer

why we should use create and copytruncate together?

The Geek Stuff has an example about logrotate. copytruncate will copy and truncate the original log file. Then why we should use create? The original log file has not been removed. /tmp/output.log { size 1k copytruncate create compress …
Majid Azimi
  • 3,018
  • 6
  • 31
  • 37
29
votes
4 answers

How can I set up logrotate to rotate logs hourly?

According the the Unix and Linux Administration Handbook and man, logrotate has options for daily, weekly, and monthly, but is there a way to add an hourly option? This blog post mentions you can set size 1 and remove the time option (eg: daily) and…
cwd
  • 44,479
  • 71
  • 146
  • 167
28
votes
2 answers

How to avoid apache reload when rotating logs?

I use logrotate to rotate Apache access-, error- and rewrite-logs. My config file looks like this: /apache/*log { compress dateext rotate 365 size=+300M olddir /log/old/apache notifempty missingok lastaction …
harp
  • 1,017
  • 2
  • 13
  • 16
22
votes
2 answers

Rotating log files while process still running

I have a process running that writes standard output and standard error to a log file /var/log/dragonturtle.log. Is there anyway to rotate the log file, and have the process continuing to write to the new log file without killing the process? What…
DanielGibbs
  • 475
  • 2
  • 5
  • 13
21
votes
6 answers

how to implement logrotate in shell script

test.sh #!/bin/bash echo "Hello World" test2.sh #!/bin/bash while true do sh test.sh >> /script_logs/test.log & done I want to implement logrotate to control the log file size, so how to implement the logrotate, if the situation is like above?
Veerendra K
  • 520
  • 2
  • 9
  • 24
19
votes
1 answer

logrotation - rotate and maxage command

Can anybody please explain me about the function of 'rotate' and 'maxage' in logrotation as this is very confusing . consider am using the below values in my script: rotate 30 maxage 30 Thank you..
Abhilash
  • 213
  • 1
  • 2
  • 5
15
votes
6 answers

Keep log file size fixed without logrotate

Is there any way to keep file size of log file fixed without rotating it by a new empty file and deleting (or archiving) the old file. For example, if I set log file maximum size to 1MB, after the file size increase beyond that limit it will be…
uray
  • 3,830
  • 11
  • 36
  • 42
13
votes
1 answer

learning about general logging/logrotation on linux?

Assume, that beside the Apache web server logs I never had any contact with any kind of (professional) logs on any operation system. So Logging, although I understand some basics, is all together a pretty new topic. At the moment the investment to…
erikbstack
  • 940
  • 2
  • 9
  • 16
11
votes
2 answers

How to properly logrotate logs of service managed by systemd via `file:` config

I have a service managed by systemd that has the following systemd config telling systemd to write the logs to a file directly (no syslog or anything) StandardOutput=file:/var/log/foo/my.log I have a logrotate rule /var/log/foo/*.log { …
Hilikus
  • 223
  • 2
  • 7
11
votes
4 answers

How can I properly override logrotate policies?

Various Debian packages, including logrotate and rsyslog, put their own log rotation definitions in /etc/logrotate.d/ What is the correct way to override those definitions? If I modify the files, I get warnings at every system update and I risk…
Tobia
  • 669
  • 8
  • 14
11
votes
5 answers

nginx logrotate error on cron job

I'm running Ubuntu 14.04 LTS and nginx on a Digital Ocean VPS and occasionally receive these emails about a failed cron job: Subject Cron test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) The body of the email…
Chris
  • 113
  • 1
  • 5
11
votes
3 answers

solution to rotate log files

I am running a daemon process that will have to run indefinitely (a 'service' so to speak) and wish to log its output. A simple solution like: ./long-running-process > log.out & ... fails as the file log.out: soon exceeds the size that I can…
Marcus Junius Brutus
  • 4,427
  • 11
  • 43
  • 63
1
2 3
18 19