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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. blurlock Command Examples in Linux
  2. How To Migrate Existing Iptables rules to Nftables In CentOS/RHEL 8
  3. restorecon: command not found
  4. tc: command not found
  5. How To Disable Or Extend System Logging Rate-limit on CentOS/RHEL 6
  6. How to increase swap space on Linux
  7. mate-search-tool Command Examples in Linux
  8. needrestart: command not found
  9. Interview Questions : Linux Package Manager (RPM)
  10. Linux OS Service ‘yppasswdd’

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright