LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-30-2006, 10:00 PM   #1
yongitz
Member
 
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139

Rep: Reputation: 20
firewall logs and cron


hi everyone! currently im working on with my firewall logs on a daily basis. i am using log utility of linksys router and have it configured over my redhat box. i check the logs of the previos day with the following commands:

grep '\[OUT\]' lsys_monitor.log | grep '2006-05-30'

the problem is it takes me a bit longer to wait for the logs to display. i am curious if somehow i can use cron to do the job for me, and pipe its output to a tmp file like:

0 5 * * * grep '\[OUT\]' lsys_monitor.log | grep '2006-05-30' > /tmp/log.txt

but the problem with this command is that everyday i have to edit my crontab entry to get the exact log date like in this case the "2006-05-30" entry.

if somehow i could replace that entry with a command that would automatically get the previous date as the cron job runs...

can u please give me suggestions? or any advice on how will i make it... thank you ppl in advance!!
 
Old 05-30-2006, 10:21 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You could just run the cron job a few seconds before midnite...

Update: Here's a sample crontab entry:

Code:
59 23 * * * /bin/grep '\[OUT\]' lsys_monitor.log | /bin/grep "`/bin/date '+%Y-%m-%d'`" > /tmp/log.txt

Last edited by macemoneta; 05-30-2006 at 10:25 PM.
 
Old 05-31-2006, 09:13 PM   #3
yongitz
Member
 
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139

Original Poster
Rep: Reputation: 20
hi there!! tnx for the immediate reply.. ive tried the command but when i checked it today.. nothing happens.. what exactly will that command do??
 
Old 05-31-2006, 09:28 PM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
59 23 * * * /bin/grep '\[OUT\]' lsys_monitor.log | /bin/grep "`/bin/date '+%Y-%m-%d'`" > /tmp/log.txt

At 23:59 (one minute before midnight), grep for the string '[OUT]' in the file lsys_monitor.log (you need to specify the path; this is all you provided), then pipe the result to another grep which will look for the date in the format yyyy-mm-dd (as you specified in your request), then send the result to the file /tmp/log.txt.

As noted above, you need to specify the actual location of the lsys_monitor.log file.
 
Old 06-01-2006, 05:09 AM   #5
yongitz
Member
 
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139

Original Poster
Rep: Reputation: 20
whew!! thanks agen.. sorry for my stupidity..
 
Old 06-05-2006, 01:30 AM   #6
yongitz
Member
 
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139

Original Poster
Rep: Reputation: 20
thanks dude! now it works just the way i want it to be.. just have 2 remove the double-quotation (" ") though to get it working... thanks agen..
 
  


Reply


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
Mailing daily logs via cron? ladyath Linux - General 3 03-29-2005 11:51 PM
how to silence script output (so I don't get so many cron logs)? BrianK Programming 2 03-01-2005 04:53 PM
Firewall logs in logs and terminal... robbow52 Debian 7 11-20-2004 07:13 PM
Separate firewall logs and general logs dominant Linux - General 3 04-20-2004 01:26 AM
keeping logs from a cron job dominant Linux - Newbie 2 03-02-2004 11:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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