Questions tagged [logrotate]

A program for managing and archiving individual log files. It allows automatic rotation, compression, removal, and mailing of log files. Jobs can be configured to run hourly, daily, weekly, monthly, yearly or when reaching a certain size or age.

Filter by
Sorted by
Tagged with
41 votes
2 answers
64k views

Specify the time of daily log rotate

I noticed that daily log rotations which are listed under /etc/logrotate.d/ are executed in the morning around 6:40 am. This is clear from the beginning and ending of the log files. Can I customize ...
Khaled's user avatar
  • 1,672
27 votes
1 answer
44k views

What schedules logrotate?

I'm working on the program which creates a big log file. I want to handle it with logrotate. This is a configuration I put to /etc/logrotate.d/: /var/log/myproject.log { hourly maxsize 1 rotate ...
user2136963's user avatar
23 votes
1 answer
23k views

Configuring logrotate without root access (per user log rotation)

How best can logrotate be configured, on a per-user basis, to rotate files in the home directory of the user, under control of a per-user crontab -e?
Bryce's user avatar
  • 1,937
10 votes
5 answers
35k views

/var/log/syslog not rotating

Our log file /var/log/syslog does not seem to be rotating, even though the logrotate config /etc/logrotate.d/rsyslog exists: /var/log/syslog { rotate 7 daily missingok notifempty ...
Justin's user avatar
  • 521
10 votes
2 answers
2k views

Upstart not reopening log files on logrotation

We use upstart to manage our services on our Ubuntu servers. They produce logs which are logged out to /var/log/upstart/SERVICE_NAME.log Then daily, the log files are rotated using the logrotation ...
Andrew Newdigate's user avatar
9 votes
2 answers
17k views

Which script rotates /var/log/auth.log?

I cannot figure out where /var/log/auth.log is rotated. I found the file /var/log/auth.log.2013-09-16 on my system, which contains log entries previously found in /var/log/auth.log. Where does that ...
Oswald's user avatar
  • 191
8 votes
2 answers
16k views

Purpose of "postrotate invoke-rc.d rsyslog rotate" when logrotating, and is this command outdated?

When using logrotate to keep log files rotating, I have seen postrotate invoke-rc.d rsyslog rotate > /dev/null endscript I know postrotate makes bash execute the following command ...
fpghost's user avatar
  • 1,659
7 votes
1 answer
8k views

What is the syntax for commenting out lines in logrotate config files?

Not sure if this is possible at all. And what about empty lines? Update: Testing the config with logrotate -d /etc/logrotate.d/apache2 returns error: /etc/logrotate.d/apache2:1 lines must begin ...
Reto Höhener's user avatar
7 votes
2 answers
38k views

How To rotate syslog daily?

I want to rotate my syslog daily... How do I do this? How to check whether log rotate is working? How to make it run daily? By default, does Ubuntu Server run logrotate daily? Or do I have to set it ...
THpubs's user avatar
  • 2,795
7 votes
3 answers
9k views

Nginx logrotate logs

I am running Ubuntu 15.04 and have a standard installation of nginx (apt-get install nginx) running. Everything is running fine but I notice that the nginx logs are being rotated but nginx carries on ...
willwade's user avatar
  • 173
7 votes
2 answers
39k views

Ubuntu 14.04 - logrotate does not rotate /var/log/* (rsyslog config)

I have a bunch of Ubuntu 14.04 servers I manage where logrotate is not rotating anything under /var/log/*. I'm going to assume its an issue with the /etc/logrotate.d/rsyslog as I see other entries in /...
ServerNinja's user avatar
7 votes
1 answer
19k views

logrotate fails to rotate logs: error setting owner

Recently I've noticed that logrotate does not rotate my logs. user1@host:~$ /usr/sbin/logrotate /home/user1/logrotate.conf -v gives me an error: error: error setting owner of /home/logs/mylog.log.1 ...
hdf's user avatar
  • 171
6 votes
2 answers
9k views

logrotate succeeds when manually run as root, but fails with "Read-only file system" when run by logrotate.service

I have a (formerly working) logrotate setup for OpenResty that I took from a previous Ubuntu 18.04 installation. Yet the logrotate.service fails with this error now ... error: error renaming /usr/...
Philipp Claßen's user avatar
6 votes
3 answers
13k views

How to prevent logs from getting too big?

I have a cronjob that runs some Python scripts and they generate massive log file. How do I prevent them from getting so big? It'd be perfect if the file was deleted once it hit a certain size. ...
User's user avatar
  • 161
6 votes
3 answers
9k views

MySQL logrotate error

I'm new to Linux and have setup a VPS running Ubuntu 16.04 with postfix, dovecot and rouncube using mariadb for the database. It all seem to be working okay but I regularly receive the following email:...
Adam D's user avatar
  • 61
6 votes
2 answers
29k views

Log files are taking too much space and I can't delete\clear them

After using Ubuntu for 2.5 months, my /var directory reached around 37 GB or RAM while my / directory is all 50 GB or RAM and the rest of space is for my /home. I found that the following files are ...
Muhammad Gelbana's user avatar
5 votes
1 answer
42k views

Why is logrotate not running automatically?

I have set up a Syslog-ng server with some filters to split certain traffic into different files. I modified the logrotate file located at /etc/logrotate.d/syslog-ng to rotate these files daily, but ...
John K.'s user avatar
  • 261
5 votes
1 answer
9k views

How can I configure logrotate to copy/SSH apache log files

I'm working on an apache logs analyser, it requires the apache log files to be imported into a directory for processing. I cannot simply point it to the apache logs directory as it imports each file ...
Stephen RC's user avatar
  • 4,812
5 votes
1 answer
11k views

How to set size for system log

My server dumps because of huge system log files. I've heard that we could limit the size of system log by adding such a line size 100m into the file /etc/logrotate.d/rsyslog to do so. Now my /etc/...
Yves's user avatar
  • 1,288
5 votes
3 answers
3k views

Why do only some of my logs get rotated?

I'm using Ubuntu 14.04. I have the following in my /etc/logrotate.conf file ... /home/rails/myproject/log { daily rotate 3 compress delaycompress missingok ...
Dave's user avatar
  • 2,095
4 votes
2 answers
11k views

Logrotate configuration: it works, but always keeps 'current' log empty

I moved logging for openvpn into its own log and attempted to set up log rotation for it, but I've obviously done something wrong. Logging occurs as desired but always into the 2nd logfileopenvpn.log....
Organic Marble's user avatar
4 votes
1 answer
6k views

How to change the day of the week Logrotate shifts the file when configured weekly?

I have following configuration which rotates all content of google folder weekly: /var/log/google/*.log { create 0777 www-data www-data weekly missingok rotate 90 ...
dragosrsupercool's user avatar
3 votes
1 answer
4k views

Ubuntu 22.04: Logrotate not working after upgrade to Ubuntu 22.04

I just realized that since the upgrade to 22.04.1, logrotate is not working. Syslog hasn't been rotated for many days. It's supposed to be run by systemd timers, and the related timer is activated: # ...
ThinkHard's user avatar
  • 303
3 votes
1 answer
5k views

Logrotate: Using multiple criteria for rotating

How can I set a rotating policy based on a disjunction of size and frequency criteria. I have tried the following: "/var/log/uwsgi/*/*.log" { ... size 400M daily rotate 14 .. } However, ...
Adam Matan's user avatar
  • 12.5k
3 votes
1 answer
24k views

Logrotate: run every N hours

Consider a server which generates extensive logging, which are archived using logrotate and bz2: "/var/log/uwsgi/*/*.log" { copytruncate daily rotate 14 compress delaycompress missingok ...
Adam Matan's user avatar
  • 12.5k
3 votes
1 answer
12k views

How can I configure logrotate without having `/etc/logrotate.d/rsyslog`?

I am trying to configure log rotation on my Ubuntu machine so that logs are rotated every day and kept for 14 days. Most tutorials I find, such as this one, mention that I should modify /etc/logrotate....
Aras's user avatar
  • 819
3 votes
2 answers
3k views

Using logrotate to manage logs generated by PHP

My PHP scripts generate log files and I am trying to use logrotate to manage them. File /etc/logrotate.d/php-logs: /srv/cache/*.log { daily notifempty size 800K rotate 5 missingok ...
bearcat's user avatar
  • 203
3 votes
1 answer
10k views

How to rotate a log file in ubuntu on size basis hourly?

/opt/variable/log/myapp.log { rotate 24 hourly maxsize 10k compress ifempty postrotate reload rsyslog > /dev/null 2> & 1 || true endscript } I have copied ...
ams's user avatar
  • 213
3 votes
1 answer
1k views

Ubuntu 20.04.3: nginx crashes with segfault

I have an Ubuntu box (20.04.3) on which nginx stopped already twice with a segfault: Nov 16 00:01:23 documents-oo kernel: [2726316.050697] nginx[2579242]: segfault at 41 ip 00007fbf59548593 sp ...
Bernd Lentes's user avatar
3 votes
0 answers
315 views

How to force log rotation more than one time in a day?

I'm trying to force the Apache logs rotations by executing sudo logrotate -f /etc/logrotate.d/apache2. When I executed the command for the first time, I get the logs rotated correctly. But if I ...
user avatar
3 votes
0 answers
1k views

how to make logrotate.d daily rotate each day at 00:00 exactly

I've followed the method shown at https://askubuntu.com/a/24526/498355 to make daily logrotate.d rotate at exactly 00:00. I have 2 physical servers which ubuntu 16.04 with the same date and timezone. ...
cherouvim's user avatar
  • 215
2 votes
3 answers
4k views

how to change file permission of a file permanently that is set back to default on boot

I have a file /var/logs/apache2/error.log. And every time I boot, Its file permission is changed to default (unwritable) by the system. So, i have to run chmod command every time i boot-up. How to ...
S L's user avatar
  • 1,919
2 votes
1 answer
2k views

Cannot run logrotate utility automatically from cron

I run sudo crontab -e and append the following line: * * * * * logrotate -f /etc/logrotate.d/adraw; touch /ADraw/Data/Logs/test.txt The file test.txt is successfully created, but I see no results of ...
Apogentus's user avatar
  • 189
2 votes
1 answer
6k views

logrotate - file owner issue

I want to rotate the syslog for testing. sudo logrotate -f /var/log/syslog [sudo] password for stephen: error: Ignoring /var/log/syslog because the file owner is wrong (should be root or user with ...
Stephen Boston's user avatar
2 votes
1 answer
997 views

How to configure logrotate in a default, most basic conf for an all-default system?

I have an all-default Ubuntu VPS machine with Nginx, for a few light WordPress sites with say up to 5 plugins, 10 webpages, 20 images each. So far I cleaned all default logs (or at least some of them)...
Arcticooling's user avatar
2 votes
1 answer
3k views

What is the easiest way to setup Log rotation [duplicate]

Recently, I have setup a script that outputs to a single log file... After quite a while this file begins to become too large to manage. I was wondering what the easiest way is to setup log rotations ...
NerdOfCode's user avatar
  • 2,518
2 votes
2 answers
4k views

How to compress , keep and empty original file with gzip

For some reason I'm not being able to use logotate to compress files periodically. So I decided to write my own script, it's not the most hard thing but one small detail is pinning me down. When using ...
storm's user avatar
  • 4,973
2 votes
1 answer
2k views

Can logrotate suffer race conditions?

I have a PHP application that can generate quite a lot of log information. I'd like to use logrotate to make sure these logs don't get out of hand over time. However, I'm concerned about race ...
Alex's user avatar
  • 329
2 votes
0 answers
394 views

Each day when the logs turn over, the system fails to find space even though there is plenty on the device; potential error with init.d script

I'm still at a loss for this specific error and any help or pushing in the right direction would be much, much appreciated. TL;DR: Many, many instances of an init.d spawned script seem to be running, ...
user3684314's user avatar
2 votes
2 answers
3k views

Setting a size limit for current syslog

Based on other threads, the only way to set a size limit on current syslog (/var/log/syslog) seems to be via rsyslog which is a bit tricky. I ended up replacing the line below in /etc/rsyslog.d/50-...
Nerssi's user avatar
  • 21
2 votes
0 answers
666 views

Logrotate not doing his job, hdd full because of logs

I have a small microSD ( 3GB ) on a ARM Samsung Artik, with Ubuntu installed. I have installed syslog-ng and Logrotate to manage my logs, because otherwise my memory get filled quickly. My problem ...
Juliatzin del Toro's user avatar
2 votes
1 answer
1k views

How to rotate graphite's logs?

We have the graphite-web package installed, which came with its /etc/logrotate.d/graphite-web. Unfortunately, the "out-of-the-box" file is broken -- the files are rotated, but the daemons writing ...
Mikhail T.'s user avatar
2 votes
1 answer
1k views

logrotate seems work incorrect

I'm using: Linux workdesk 3.16.0-31-generic #43~14.04.1-Ubuntu SMP Tue Mar 10 20:13:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Distributor ID: Ubuntu Description: Ubuntu 14.04.2 LTS Release: 14....
Ilia's user avatar
  • 21
1 vote
3 answers
512 views

Logrotate on "not always on" system

I have several Ubuntu 16.04 and 18.04 systems, whose have no defined operating hours, for example desktop, laptop or VMs runt on demand. What are the right ways and tools to automatically rotate logs ...
Koguni's user avatar
  • 51
1 vote
2 answers
5k views

Ubuntu 18.10 Tomcat8 catalina.out file path

In previosu version, I saw that the catalina.out file was created at /var/log/tomcat8/catalina.out location. As I was study for my current installation, Ubuntu 18.10 and last package version, I saw ...
Etienne's user avatar
  • 11
1 vote
1 answer
1k views

How do I identify which log is incorrectly rotated?

I'm receiving email prompts from two Ubuntu 14.04 servers around unusual logrotate behaviour. I don't have any packages installed which are not installed on other servers which don't exhibit this ...
Arronical's user avatar
  • 19.9k
1 vote
3 answers
1k views

tail stops displaying in case of a log rotation

I have to tail the log of a server (servicemix) and the log rotation is enabled. As soon as the rotation happens, tail stops displaying. I did some investigations and it is a bug in Debian : Debian ...
Rudy Vissers's user avatar
1 vote
1 answer
4k views

/var/log/syslog not getting rotated

I have a fresh install of ubuntu 20.04. I have set daily rotation in /etc/logrotate.d/rsyslog file with a maxsize of 1M but the /var/log/syslog and kern.log file keeps increasing. Here is the rsyslog ...
AjayC's user avatar
  • 398
1 vote
2 answers
8k views

Where should I look for logrotate config file of /var/log/mail.log

I would like to change the suffix of mail.log rotated files to include the date, such as /var/log/mail.log.20180920 I read from this question that /etc/cron.weekly/sysklogd should be changed, but I ...
Alex's user avatar
  • 211
1 vote
1 answer
421 views

Best ways to manipulate system logs

I want to manipulate logs. So far, for me the best way to clear system logs is: truncate -s 0 /var/log/*log I'm searching for the best ways to: 1 - Do the above periodically. I have already try ...
ioaniatr's user avatar
  • 1,301