LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-28-2013, 03:37 AM   #1
ashokkvnit
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Rep: Reputation: Disabled
logrotate cron job not rotating certain logs


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

Quote:
<myLogFilePath> {
compress
copytruncate
delaycompress
dateext
missingok
notifempty
daily
rotate 30
}
There is a "logrotate" script in "cron.daily" directory (which seems to be running daily as per cron logs):

Quote:
#!/bin/sh

echo "logrotate_test" >>/tmp/logrotate_test
#/usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1
/usr/sbin/logrotate -v /etc/logrotate.conf &>>/root/logrotate_error

EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
The first echo statement is working.
But I find my application logs alone are not getting rotated, whereas other logs like httpd are getting rotated
And I also don't see any output in the mentioned "logrotate_error" file (has write permission for all users).

However the syslog says: "logrotate: ALERT exited abnormally with [1]"

But when I run the same "logrotate" in "cron.daily" script manually, everything seems working fine.

Why is it not rotating during daily cron schedule? Am I doing something wrong here?
It would be great if I get this much needed help.
 
Old 03-28-2013, 03:42 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
1. so, what error msg is being put into /root/logrotate_error ?

2. in any case, check ownerships and perms of your script is the same as the others in that logrotate.d
 
Old 03-28-2013, 03:49 AM   #3
ashokkvnit
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for your reply.

1. As I have mentioned, I didn't find any output in that "/root/logrotate_error" file - which has write permission to all users(even though the first echo statement is working).

2. Scripts for my application logs does not have write permission - I don't see that as a problem though, because the same was working on other VMs.
 
Old 04-02-2013, 08:32 AM   #4
ashokkvnit
LQ Newbie
 
Registered: Mar 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
It looks like, it's because of selinux - the log files in my user home directory has restrictions imposed by selinux and the when logrotate script is run:

Quote:
SELinux is preventing /usr/sbin/logrotate from getattr access on the file /home/user/logs/application.log.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
logrotate cron job not rotating certain logs ashokkvnit Linux - Software 4 04-02-2013 10:44 AM
[SOLVED] Logrotate Logs not rotating Ubunutu 12.4 LTS 116Fanatic Linux - Server 5 01-04-2013 01:51 PM
Cron job to display new message every time user logs in rahilmaknojia Linux - Newbie 4 09-12-2012 05:35 PM
Backing up and/or delete logs with a cron job. NaCo Linux - Server 2 08-01-2009 03:16 AM
keeping logs from a cron job dominant Linux - Newbie 2 03-02-2004 11:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration