logrotate cron job not rotating certain logs

后端 未结 6 1064
生来不讨喜
生来不讨喜 2021-02-05 14:01

I added two scripts in \"logrotate.d\" directory for my application logs to be rotated. This is the config for one of them:

 {
  compress
           


        
6条回答
  •  萌比男神i
    2021-02-05 14:53

    I had a similar problem. To resolve this, I first checked the status of SELinux using the sestatus command:

    # sestatus
    SELinux status:                 enabled
    SELinuxfs mount:                /selinux
    Current mode:                   enforcing
    Mode from config file:          enforcing
    Policy version:                 24
    Policy from config file:        targeted
    

    Then, check the SELinux security context applied to files and directories using ls --scontext. Check the files you want logrotate to operate on, and check files that are working, such as /var/log/maillog:

    # ls --scontext /var/log/maillog*
    system_u:object_r:var_log_t:s0   /var/log/maillog
    system_u:object_r:var_log_t:s0   /var/log/maillog-20140713
    system_u:object_r:var_log_t:s0   /var/log/maillog-20140720
    system_u:object_r:var_log_t:s0   /var/log/maillog-20140727
    system_u:object_r:var_log_t:s0   /var/log/maillog-20140803
    

    Use semanage to change the file context.

    semanage fcontext -a -t var_log_t 
    restorecon -v 
    

提交回复
热议问题