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
3
votes
2 answers

Null bytes in a file created by 2> rotated with logrotate?

I'm using the script utility to record terminal sessions, and using logrotate (with copytruncate, script ignores HUP and keeps writing to the rotated file otherwise) to periodically upload chunks of what's happened so far to another server. This…
Jeremy Wadhams
  • 877
  • 2
  • 9
  • 19
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
  • 5
  • 22
3
votes
2 answers

Logrotate doesn't work from cron on CentOS

I have lograotate configured on CentOS 6. It works fine when I run it manually, but with CRON it doesn't work. Cron says in its logs: "All fine, I run you command" but nothing happens. Details: cat…
odiszapc
  • 151
  • 1
  • 2
  • 6
3
votes
2 answers

Logrotate: rotate all log files on specific size and rotate hourly

My logrotate file on ubuntu runs daily. I want to make sure its rotating log files in every hour to get no full disk error anymore. So my logrotate file is in the cron.daily folder, is it enough to simply move it to cron.hourly? I also want to keep…
martintrapp
  • 177
  • 1
  • 1
  • 5
3
votes
1 answer

rotating logs with logrotate

I want to schedule logs rotate with these rules: log files for the last 2 day are kept untouched log files older than 2 days are archived and moved to folder named by date, they were created. (For ex. All logs for 01 Dec 2012 are moved to 20121201…
user148378
  • 33
  • 4
3
votes
3 answers

logrotate: keep N newest files, but don't rename

I have a service that automatically creates a log file with a timestamp in the filename on startup. Thus, I don't need logrotate to rename/copy/create files, but what I do want is that logrotate shall keep just the three newest of those files (and…
Michael
  • 285
  • 4
  • 16
3
votes
1 answer

Logrotate directories (not files)

I have an application creating logfiles in a structure like this: maillog/ 2012-07-02/ production_environment-2012-07-02__23_51_50-1341265910-some name.log production_environment-2012-07-02__23_51_52-1341265912-some other name.log ... …
FadenB
  • 31
  • 2
3
votes
3 answers

logrotate security

Are there any concerns about the security of logrotate running as root? Had someone ask couldn't a malicious user subvert the config to overwrite anything? Is is okay to run logrotate out of the cron of another user?
pzod
  • 117
  • 2
3
votes
1 answer

logrotate compress only last n logs

I need to make a daily rotate of /var/log/messages to be kept for 60 days, where the last 30 logs must be compressed with bzip2. This is my logrotate config: /var/log/messages { …
Peter
  • 31
  • 2
3
votes
1 answer

FreeBSD 8.1 64bit logrotate - ELF interpreter /libexec/ld-elf-so.1 not found

I am trying to get logrotate running on a FreeBSD 8.1 virtual machine. I installed the logrotate with pkg_add, I have created the logrotate.config file and also run: mkdir /var/lib/ touch /var/lib/logrotate.status Now when I…
Richard Knop
  • 1,149
  • 2
  • 20
  • 34
3
votes
3 answers

nginx logrotate config

Whats the best way to rotate nginx logfiles? In my opinion, I should create a file "nginx" in /etc/logrotate.d/ and fill it with the following code and do a /etc/init.d/syslog restart after that. This would be my config (I havn't tested it yet): …
TomOP
  • 43
  • 1
  • 1
  • 3
3
votes
4 answers

Logfiles go blank after logrotate rotates them

I have an ubuntu 8.04 LTS server that runs openvpn. The openvpn server writes to a standard logfile under /var/log and prior to a month ago logrotate would automatically rotate the files and compress them. The files are still being rotated however…
Hilton D
  • 279
  • 5
  • 15
3
votes
2 answers

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

I am new to Linux/CentOS and right now I am running into a little problem. My CentOS7 Server logs all Maillogs, via Logrotate, on a daily basis and moves them to the folder /var/log/old_maillogs. Right now the logs are saved with a name similar to…
Moritz
  • 65
  • 9
2
votes
1 answer

log-rotation not working properly

I have created log rotation but it seems not working for me, as it's creating a large number of files like "smartfox.log.2020-01-05-07.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1" Furthermore, rotate 3 and maxsize 100M is also not working as I am seeing…
Ashish Karpe
  • 277
  • 2
  • 5
  • 19
2
votes
1 answer

How to move compressed files with logrotate

This is probably insanely easy to do, but I can't find anything relevant to the topic. I'm setting up a custom logrotate.conf file for the logs in our service. As part of this, I would like to keep logs up to 7 days, compress antything older than…
SVill
  • 77
  • 3
  • 13