Log rotation not working in Centos 7.2


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Log rotation not working in Centos 7.2
# 1  
Old 08-04-2016
Log rotation not working in Centos 7.2

All,

I am facing an issue as log rotation not working for me as expected for tomcat in centos 7.2. I configured log rotation command in crontab

Code:
*/5 * * * * root /usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1

I am trying to rotate below tomcat logs owned by application userID.
/usr/local/tomcat/logs

Code:
ls -ltr catalina*
-rw-r-----. 1 appid appgrp       8910 Jun 17 19:28 catalina.2016-06-17.log
-rw-r-----. 1 appid appgrp     104739 Jun 20 17:28 catalina.2016-06-20.log
-rw-r-----. 1 appid appgrp      26051 Jul  1 17:00 catalina.2016-07-01.log
-rw-r-----. 1 appid appgrp      39238 Jul 20 20:34 catalina.2016-07-20.log
-rw-r-----. 1 appid appgrp 6141522000 Aug  4 19:05 catalina.out

if you see above files it's a 6GB of catalina.out where it should get rotated at 10M itself which didn't happen.

Code:
CentOS Linux release 7.2.1511 (Core)

/usr/local/tomcat/logs/catalina.out
{
    rotate 25
    size 10M
    missingok
    start 0
    nodateext
    notifempty
    compress
    delaycompress
    copytruncate
    create 744 crtc crtc
    sharedscripts
    postrotate
    endscript
}


I checked audit logs and found below error message

Code:
type=AVC msg=audit(1470324541.165:210294): avc:  denied  { create } for  pid=11644 comm="logrotate" name="catalina.out.0" scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:usr_t:s0 tclass=file
        Was caused by:
                Unknown - would be allowed by active policy
                Possible mismatch between this policy and the one under which the audit message was generated.

                Possible mismatch between current in-memory boolean settings vs. permanent ones.


type=AVC msg=audit(1470325921.157:98): avc:  denied  { write } for  pid=2790 comm="logrotate" name="catalina.out.0" dev="vda1" ino=658223 scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:usr_t:s0 tclass=file
        Was caused by:
                Unknown - would be allowed by active policy
                Possible mismatch between this policy and the one under which the audit message was generated.

                Possible mismatch between current in-memory boolean settings vs. permanent ones.

I tried to create a logrotate_t.pp file still no luck. It's working only when I put selinux in permissive mode it's working

Code:
# getenforce
Permissive

Is there any alternate work around to deal this issue as I don't want to keep selinux in permissive mode.

Thanks in advance.
Shekar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Log rotation in PowerHA7

Hi All, I have a situation here ... HACMP is configured with application monitoring script, which is generating messages .... which is running every minute ... And every minute when monitoring script run, one one log file is generating .... and this log file is rotating ... which is rotating... (1 Reply)
Discussion started by: linux.amrit
1 Replies

2. OS X (Apple)

Mavericks log rotation

In Mavericks, Apple has apparently moved control of log rotation to ASL. There's a 'ttl' value to determine how long log files will stick around for. I can compress them, change the way they're named, limit them by size, etc. But the one thing I cannot find is how to NOT keep one log file per... (0 Replies)
Discussion started by: jnojr
0 Replies

3. Shell Programming and Scripting

Log rotation script

I have an application that rotate its log once it reaches 100mb and it keeps a total of 24 logs. I am trying to write a script to run daily to tar up the previous day logs files and move them to a different directory. here is a long listing of the logs in the directory: -rw-r--r-- 1 user1 ... (6 Replies)
Discussion started by: e_mikey_2000
6 Replies

4. Solaris

Log rotation

Hi All! I seem to have a problem with log rotation, unless I am doing something wrong, I have type the following command for testing purposes to see if the -s option works but he did not: logadm -w /var/adm/messages -C 8 -c -s 512k -t '/var/adm/messages.$n' -z 1 the file is now at this... (7 Replies)
Discussion started by: fretagi
7 Replies

5. UNIX for Dummies Questions & Answers

Log Rotation

Hi Guys, Good morning, I just want to know and collect ideas on this one. Regarding rotation of logs as I've observed it's not consistently functioning. I have a server with 8 Partitions, each partition has a dedicated directory for the logs that is needed and I set it every 5mins (300secs) the... (1 Reply)
Discussion started by: rymnd_12345
1 Replies

6. Solaris

Log rotation, twice

hi folk, need advise regarding the log rotation, i have the logadm set at 30 2 * * * /usr/sbin/logadm so it supposed to rotate once per day, but now it rotated twice! but someone my log will rotate at 2:30 AM, but then another 2 hours later, it creates a new and rotate a new log again,... (2 Replies)
Discussion started by: dehetoxic
2 Replies

7. Solaris

Solaris log rotation

HI, What is log rotation in Solaris ? What are the essential steps to perform log rotation in Solaris? (1 Reply)
Discussion started by: Revathi@1
1 Replies

8. Shell Programming and Scripting

Log file rotation

Hi I am trying to create a simple function that implements log rotation rotatelogs () { file_name=$1 archive_dir=$2 retention_period=$3 find $archive_dir -name $file_name -mtime +$retention_period -exec rm -f {} \; } Issue i am facing is the file_name would be something like my... (3 Replies)
Discussion started by: xiamin
3 Replies

9. Shell Programming and Scripting

log rotation

Hello all. Due to some reason I can not use HUP to rotate needed log files. So I use the standard method: cp $file $file.1 cat /dev/null > $file But if Java application in this time writing the output to $file, in the beginning of it appears many "^@^@^@^@^@^@". How to avoid it? Or how... (6 Replies)
Discussion started by: mirusnet
6 Replies

10. HP-UX

Log rotation on HP-UX

Can anyone post a sample log rotate and archive configuration on HP-UX? I really don't know how to do that... :( (3 Replies)
Discussion started by: untamed
3 Replies
Login or Register to Ask a Question