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
2
votes
1 answer

Endless files with copytruncate option in logrotate

When I use logrotate with this configuration: /home/ubuntu/.pm2/logs/* { rotate 2 size 200k missingok notifempty compress delaycompress copytruncate create 0640 ubuntu ubuntu } My file…
Andy
  • 151
  • 7
2
votes
0 answers

Make logs append-only with logrotate

I was wondering if it's possible to use prerotate and postrotate in logrotate.conf. The thing is I want to make logs append only, normally I'd add chattr -a to prerotate and chattr +a to postrotate in scripts in /etc/logrotate.d, but what if I want…
J91321
  • 176
  • 8
2
votes
1 answer

Fail2ban reading logs from the syslog/process/stdout of other task

I have a list of docker containers running on a server. One of the containers is (will be) fail2ban running on privileged mode. My problem right now is with passing and sharing the same volume (log file) through these containers in order for it to…
Romeo Mihalcea
  • 522
  • 1
  • 9
  • 27
2
votes
2 answers

Rotating a subset of logs with Logrotate

I have a number of files in /var/log/myapp/ that end in .log. So I've created a /var/log/myapp/*.log { daily create 644 rotate 90 compress missingok } And this works perfectly well. I have a number of different log types in here and I…
2
votes
0 answers

Cron not logrotating for cron.daily

I'm running a rhel7 server and I have a rsyslog logrotate config file that doesn't seem to run using cron job. It will only work if i run it manually Troubleshooting steps i took: logrotate -df /etc/logrotate.conf Result: Able to log rotate…
stiffy
  • 23
  • 3
2
votes
2 answers

nginx logs just failed weekly rotate, how do I determine why?

After I installed nginx, its logs have been rotating weekly as per a weekly cron job on Sunday 00:00 However this week the logs failed to rotate, and I can't figure out why. The only thing I can think that would have affected it is I did an apt-get…
mozboz
  • 71
  • 4
2
votes
3 answers

logrotate - run the postrotate after all processing

I have a logrotate script that is structured to rotate logs collected by syslog. Part of that script is to reload the syslog process. The problem is that the syslog reload runs for each matching log file it rotates and there are about 100 of them.…
Cliff Ennis
  • 21
  • 1
  • 3
2
votes
1 answer

logrotate says it's running but it's not

I have just set this box up as a log server so I can forward to a SIEM but the file is not rotating the way I expect. /var/log/remote/*.log { daily dateext rotate 4 compress delaycompress } If I run /usr/sbin/logrotate -d…
TheFiddlerWins
  • 2,999
  • 1
  • 15
  • 22
2
votes
2 answers

Split large Logfile with Suffix like from logrotate

after I've seen that I forgot to add a logrotate-conf for php5-fpm.log on one Server, and now seeing that it has grown REALLY big, I'm asking myself how to split this Logfile into separate ones, with a Suffix like logrotate would produce. You…
mr.alex
  • 123
  • 3
2
votes
3 answers

Apache daily logrotate

I want to create daily logs, but there's a small problem. Logs aren't being created for each day, rather they contain the previous log files. Here's my current setup, how can I change it so it only create a log file for each day? I edit the…
salep
  • 35
  • 1
  • 1
  • 8
2
votes
2 answers

Logrotate script not uploading to s3

I am trying to use logrotate to upload log files from my rails and nginx commands once a day. When I run the logrotate command manually the files successfully upload, but it never does it on its own. I have tried using lastaction and also postrotate…
John
  • 123
  • 4
2
votes
3 answers

How to make a cron script for cleaning up a log file?

I don't usually do this kind of stuff, so I just have to ask. How do I make a script which checks a log file, lets say it's named log.txt, grabs everything but the first 100 000 lines from it to a new log.txt file and deletes the old log.txt? It…
Guy395
  • 21
  • 1
  • 3
2
votes
2 answers

auditd process stops logging after logrotate script runs

I am trying to use logrotate to keep audit logs for a set period of time rather than using auditd's special rotation (from /etc/audit/auditd.conf). I have changed the max_log_file_action to IGNORE in that file. The following is my logrotate…
Linux2012
  • 21
  • 1
  • 3
2
votes
2 answers

script to rotate apache weblog

I am looking for a script that would rotate weblogs on apache. I'd like to schedule the script over cron so it could run periodically and rotate access_log and error_log for all websites on the server. Thanks, Mark
user21226
2
votes
1 answer

Cent OS logrotate is not rotating httpd log

My /etc/logrotate.d/httpd file content is /var/log/httpd/access.log { size=50M dateext maxage 90 postrotate /usr/bin/killall -HUP httpd ls -ltr /var/log/httpd/ | mail -s "$HOSTNAME: Apache restarted and log files rotated"…
bishnub
  • 23
  • 2