• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

System Log File /var/log/messages Is Getting Deleted or Trimmed Automatically (CentOS/RHEL)

By admin

The Problem

The system log /var/log/messages are getting trimmed or deleted automatically, and the old log will not be rotated to messages.1, messages.2, or so.

The Solution

The system log will be rotated by the logrotate, a cron job scheduled daily. This problem is due to an incorrect logrotate configuration. Checking the logrotate configuration file /etc/logrotate.conf below:

# rotate log files weekly

    #weekly
    # keep 40 weeks worth of backlogs
    #rotate 40

the rotation interval/times are all commented out. With this setting, the system log is trimmed without rotation.

In order to avoid this, modify the /etc/logrotate.conf and specify a proper rotation interval. For example, the configuration below:

weekly
rotate 4

This will rotate the logs weekly, and log files will be rotated four times before being overwritten. For more information on logrotate, check the man page:

# man logrotate

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to Mount Guest Qcow2 Virtual disk Image containing LVM on KVM Host Machine
  2. How to make CentOS/RHEL 7 FIPS 140-2 compliant
  3. How to Enable Debug Mode for Chronyd Service in CentOS/RHEL 8
  4. CentOS / RHEL : How to setup session idle timeout (inactivity timeout) for ssh auto logout
  5. Understanding Device Persistence and Oracle ASMLib
  6. CentOS / RHEL : How to prevent disabled repositories from being downloaded into the yum cache
  7. How to Automate Startup/Shutdown of Oracle Database and Listener on Linux
  8. watch command examples to run a command repeatedly or monitor dynamically changeable files (like /proc/*)
  9. How to extract RAR files in CentOS/RHEL 7 and 8
  10. CentOS / RHEL 7 : How to configure serial getty with systemd

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary