Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Log rotation of logrotate

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Case: log rotation of logrotate

Set logrotate for admin.log files

Rotate once a day

Keep 3 backups

Automatic rotation of files greater than 100k

On the 0600 permission for the compressed file creation after being transferred, and the group root to which the owner root belongs.

Steps:

1. First check to see if the logrotate package is installed

[root@localhost log] # rpm-Q logrotate

Logrotate-3.7.8-17.el6.x86_64

Create a log admin.log because I do not have the file admin.log in my virtual machine

[root@localhost log] # mkair admin.log

two。 Setting up Profil

[root@localhost log] # vim / etc/logrotate.d/admin

/ var/log/admin.log {

Missingok

Daily

Size 100k

Rotate 3

Create 0600 root root

Compress

3. test

Here, because the log is greater than 100K, we can rotate automatically. We can rotate manually.

Find a file greater than 100k in the system file and copy it to admin.log

[root@localhost log] # cp / etc/ssh/moduli / var/log/admin.log

[root@localhost log] # logrotate / etc/logrotate.conf

[root@localhost log] # ls-l / var/log/admin.log*

-rw-. 1 root root 125811 February 28 16:10 / var/log/admin.log

-rw-. 1 root root 127214 February 28 15:59 / var/log/admin.log-20170228.gz

You can view a compressed file at the end of .gz, indicating that the rotation log file is set successfully.

You can also force rotation through the logrotate-f command. But it doesn't make much sense, because the forced rotation will rotate regardless of whether the set conditions are met or not, and it doesn't make sense to detect whether our settings are successful or not.

Anacron delay remediation

Under special circumstances, the scheduled task is sometimes not executed, and the system will automatically remedy the anacron delay.

That is, the system automatically performs delay remediation within a certain period of time after the scheduled task does not take effect on time. We don't need to set it manually here.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report