Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
Script to delete files older than 30days

My hard disk suddenly became full and I searched around until I finally discovered that a "console.log.9" file buried in Library/Logs/Console/myname/ was 112 Gigs !

I couldn't able to open and check it properly.

I did some research and figured out the way for finding and deleting the log files older than 30 days from a specific path, using find and exec commands.

find /export/home/ftp ( -name console.log -or -name server.log ) -mtime +30 -exec rm -f {} +

But i want to rotate console.log in daily wise and Is any shell script to rotate the console.log daily.

Please help me out in this issue.

share|improve this question

marked as duplicate by splattne Dec 15 '10 at 18:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Duplicate post: serverfault.com/questions/212751/… –  sinping Dec 15 '10 at 15:06

1 Answer 1

up vote 8 down vote accepted

Add a file to /etc/logrotate.d, containing something like

/export/home/ftp/console.log {
  rotate 7
  daily
  compress
  missingok
  notifempty
}
share|improve this answer
    
+1, logrotate was built for this, no need to muck around with shell scripts. –  ThatGraemeGuy Dec 15 '10 at 8:20
    
i have one doubt,is log rotate affects the currently running jboss application. –  Jayakrishnan T Dec 27 '10 at 13:00
    
Try using the copytruncate directive –  Joril Dec 27 '10 at 13:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.