LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-15-2008, 12:55 PM   #1
mderakhs
LQ Newbie
 
Registered: Sep 2008
Posts: 1

Rep: Reputation: Disabled
logrotate does not work!


I added a file with the following content to /etc/logrotate.d:

/var/log/ocmpproxy.log {
daily
missingok
rotate 4
postrotate
touch /root/test.txt
kill -USR2 `ps aux | grep java | grep OcmpProxy | sed 's/\([a-z]*\) *\([0-9]*\) .*/\2/'`
endscript
}

When I run logrotate, (logrotate -d -f logrotate.conf), my process does not receive any signal. Even the /root/test.txt is not created!

If I run "/bin/kill -USR2 `ps aux | grep java | grep OcmpProxy | sed 's/\([a-z]*\) *\([0-9]*\) .*/\2/'`" from the command line my process receives the signal without any problem.

I am new to logrotate. I appreciate any help.
Is that wrong to call shell command in logrotate?

Thanks in advance.
 
Old 09-15-2008, 01:13 PM   #2
misconfiguration
Member
 
Registered: Apr 2007
Location: Indianapolis, Indiana
Distribution: RHEL, Fedora, AIX, HP-UX, FreeBSD, Slackware
Posts: 62

Rep: Reputation: 19
I'm not sure how picky logrotate.conf is, albeit generally a few options are specified outside of the {} configuration brackets.

I would do this;


# rotate 4 is already defined in default options of logrotate.

/var/log/ocmpproxy.log {
daily
rotate 4
missingok
postrotate
/bin/touch /root/test.txt
/bin/kill -USR2 `ps aux | grep java | grep OcmpProxy | sed 's/\([a-z]*\) *\([0-9]*\) .*/\2/'`
endscript
}
logrotate -f /etc/logrotate.conf
 
  


Reply



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
How does logrotate work? kenneho Linux - Software 5 08-24-2011 12:34 PM
logrotate invent Linux - Enterprise 1 08-19-2008 08:45 AM
My Logrotate won't work with mySQL guarriman Fedora 3 05-30-2006 05:02 AM
Pix logging on syslog... logrotate does not work logicalfuzz Linux - Software 0 03-06-2006 12:04 AM
Logrotate Help! MaverickApollo Linux - Software 3 02-19-2004 12:09 PM

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

All times are GMT -5. The time now is 08:06 AM.

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