Rsyslog, Logrotate cut to save the log date is not accurate problem

Source: Internet
Author: User
Tags rsyslog

Believe that the RSYSLOGD logrotate transfer cutting log students, will find the log after the file, will appear inaccurate date problem

For example: The June 21-generated log was transferred to the June 22 document for no reason, and the date was one day ahead of schedule.

Or even if the 21st log is transferred to the number 21st file, when you open but found that there are 20th of the contents.


After a few days of verification, finally found that there is a way to almost secure a clear separation log on a daily basis. In the last article, the general introduction of the practice, in this detail:


Configuration file for the operation:/etc/anacrontab

The content is configured as follows:

#/etc/anacrontab:configuration file for Anacron


# Anacron (8) and Anacrontab (5) for details.


Shell=/bin/sh
Path=/sbin:/bin:/usr/sbin:/usr/bin
Mailto=root
# The maximal random delay added to the base delay of the jobs
Random_delay=9 (This is a maximum random delay time)
# The jobs would be started during the following hours only
Start_hours_range=23-24 (This is the log cutting point of time, that is, only at 23 to 24 o'clock to start cutting, no accident is 23 points)


#period in the delay in minutes job-identifier command
1 cron.daily Nice run-parts/etc/cron.daily (set the time delay here to avoid overloading multiple tasks at the same time)
7 Cron.weeklynice run-parts/etc/cron.weekly
@monthly Cron.monthlynice run-parts/etc/cron.monthly


The effect of this setting is that the log will be cut at 23:59 every day, of course, to meet the conditions of the transfer, such a day (from 23:59 to today's 23:59) log will be saved in a log file.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.