LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 09-16-2005, 12:58 PM   #1
MacSob
LQ Newbie
 
Registered: Oct 2004
Location: South Jersey
Distribution: Fedora Core X
Posts: 7

Rep: Reputation: 0
compress log files created yesterday?


All,

I have just put up Red Hat ES 4.0 to function as a Cisco PIX syslog server for my enterprise. I've installed syslog-ng to replace the default install of syslog and have configured it to log all syslog events coming in UDP 514 on facility local4 to log to /var/log/aw.

This is a snippet of my syslog-ng conf file:

destination d_aw { file("/var/log/aw/$YEAR.$MONTH.$DAY.$HOUR.aw.log" template("$DATE,$HOST,$FACILITY.$PRIORITY,$MESSAGE\n")

What this gets me is a new file created hourly, comma delimited for all of the fields I need to capture and sort on, with nice and neat names such as:

2005.09.16.13.aw.log
2005.09.16.14.aw.log
2005.09.16.15.aw.log
...etc

the reason for this setup is that we collect a few gigabyes per day of PIX logs and this makes it easier to work with.

I need to be able to run a cron job nightly at midnight to compress all 24of the logfiles on the previuos day into one file with the date on it to /var/log/aw/backup/. I am a recovering Windows admin and this was a very simple .bat job that I ran nightly. I have been slowly moving to Linux but this answer seems to be eluding me.

Any and all help appreciated,

Mac
 
Old 09-16-2005, 03:55 PM   #2
XOR007
Member
 
Registered: May 2005
Location: Africa
Distribution: Ubuntu, Redhat 6.2 to 9, Centos 4, Suse 8 Ent.,Suse 9 Ent.
Posts: 51

Rep: Reputation: 15
Try this:

cd /var/log/aw;
today=`date +%Y.%m.%d`;
tar -zcvf $today.tar.gz $today.??.aw.log;
mv $today.tar.gz ./backup/;


You can also rm -f $today.??.aw.log at the end of the script if that is what you want.

Last edited by XOR007; 09-16-2005 at 03:58 PM.
 
  


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
What's the best way to compress image files in Linux? tgardner Linux - Software 2 06-03-2009 10:39 AM
Compress large files deweirdt Linux - Software 1 02-11-2004 07:18 AM
transparantly compress files on ext3 nielchiano Linux - General 2 02-04-2004 06:38 PM
Compress Files mikeshn Programming 5 06-04-2003 12:25 AM
Compress files with indirectly known path griv Linux - Software 2 12-18-2002 11:45 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

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