• 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. gpasswd Command Examples in Linux
  2. How to use auditd to monitor a file deletion in Linux
  3. rpm: command not found
  4. i3lock: command not found
  5. aspell: command not found
  6. sinfo: command not found
  7. How to use command line shell functions in Linux
  8. vdir: command not found
  9. “Device /dev/mappper/mpath25 Not Found (or Ignored By Filtering)” – error while creating physical volume with pvcreate
  10. How to use the “screen” command in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • batch: Execute commands at a later time when the system load levels permit
  • bat: Print and concatenate files
  • bastet: Clone of the game Tetris in the terminal
  • bashmarks: Save and jump to commonly used directories using 1 character commands

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright