LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-10-2011, 11:14 AM   #1
diamond_D
Member
 
Registered: Jul 2005
Posts: 51

Rep: Reputation: 0
logrotate - How to delete uncompressed logs


I'm learning some bash scripting and started by creating a basic server health monitoring script that redirects the output to /var/log/serverhealth/

Now I want to manage the archiving with logrotate. It's working but I'd like to implement a few minor tweaks.

I've configured a file called serverhealth and placed in /etc/logrotate.d/

Code:
/var/log/serverhealth/*.log {
rotate 10
monthly
compress
}
So when I check the folder I see my compressed logs along with the corresponding uncompressed logs. How do I configure to delete the original file post compression?
 
Old 10-10-2011, 02:31 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
compress will remove the uncompressed logfile. if you've just enabled compression then the old files will need manual clearing (afair)
 
Old 10-10-2011, 04:04 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
The man page on logrotate is quite helpful. There are some settings related to how you compress and so on. Give it a peek.
 
Old 11-03-2011, 09:32 PM   #4
diamond_D
Member
 
Registered: Jul 2005
Posts: 51

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by acid_kewpie View Post
compress will remove the uncompressed logfile. if you've just enabled compression then the old files will need manual clearing (afair)
The compress option does not remove the uncompressed log files automatically (new or old). Any idea on how to do this?

Quote:
delslige@ubuntu-P5K:/var/log/serverhealth$ ll
total 276
drwxr-xr-x 2 root root 4096 2011-11-03 21:10 ./
drwxr-xr-x 9 root root 4096 2011-11-03 07:48 ../
-rw-r--r-- 1 root root 0 2011-11-01 08:03 srvhealth.01-10-11_21:00:05.log
-rw-r--r-- 1 root root 4392 2011-10-01 21:00 srvhealth.01-10-11_21:00:05.log.1.gz
-rw-r--r-- 1 root root 29265 2011-11-01 21:10 srvhealth.01-11-11_21:10:05.log
-rw-r--r-- 1 root root 0 2011-11-01 08:03 srvhealth.02-10-11_21:00:04.log
-rw-r--r-- 1 root root 4217 2011-10-02 21:00 srvhealth.02-10-11_21:00:04.log.1.gz
 
Old 11-03-2011, 09:57 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Your problem is that each file has a different name, I'd say, and potentially
that your process keeps writing to the log while it is being rotated?

Last edited by Tinkster; 11-06-2011 at 01:40 PM. Reason: meh
 
  


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
logrotate for logs that change filenames badkuk Linux - Server 1 11-26-2010 02:57 AM
Logrotate doesn't rotate logs kenneho Linux - Desktop 5 03-23-2010 12:13 PM
Logrotate: Rotate Apache logs, but never delete kenneho Linux - Newbie 2 10-23-2008 06:58 AM
Logrotate: compress logs in a temp directory gbratig AIX 3 04-12-2008 10:42 PM
delete files uncompressed into wrong directory safely petersk Linux - General 3 03-04-2007 01:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:31 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