LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Closed Thread
 
Search this Thread
Old 03-28-2013, 03:35 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, 04:32 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,373

Rep: Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962
"&>>" doesn't make sense. Certainly not in bash.

# echo blah &>> afile
-bash: syntax error near unexpected token `>'

just run the logrotate entry yourself:


/usr/sbin/logrotate -v /etc/logrotate.conf

and see what happens then.
 
Old 03-28-2013, 05:42 AM   #3
ashokkvnit
LQ Newbie
 
Registered: Mar 2013
Posts: 6

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

I tried executing that script manually and checked that it's logging it's output (both stdout and stderr) in the mentioned file.
I don't know if that is to do something with bash version.
On 3.2.48, it gave the same error which you have mentioned, but on 4.1.2, where the logrotate script is running, it looks fine.
 
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.
 
Old 04-02-2013, 10:44 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,453

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate. Please, follow discussion here: http://www.linuxquestions.org/questi...gs-4175455881/
 
  


Closed Thread


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
[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
logrotate not rotating dman777 Linux - Software 3 08-23-2011 06:57 AM
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


All times are GMT -5. The time now is 02:10 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration