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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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 configure kdump in Oracle Enterprise Linux (OEL 5,6)
  2. znew Command Examples in Linux
  3. How to Trace Python Scripts using trace.py
  4. lsmod: command not found
  5. CentOS / RHEL 7 : Configuring NTP using chrony
  6. udevadm Command Examples in Linux
  7. “comm” Command in Linux with Examples
  8. How To Send Mails To an External User With Mailx on Linux
  9. CentOS / RHEL 6 : How to boot into rescue mode
  10. How to Create a Bridge Interface Using nmcli in CentOS/RHEL 7 and 8

You May Also Like

Primary Sidebar

Recent Posts

  • fprintd-delete Command Examples in Linux
  • fprintd-delete: command not found
  • foreman: command not found
  • foreman Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright