Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-30-2006, 10:00 PM
|
#1
|
Member
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139
Rep:
|
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!!
|
|
|
05-30-2006, 10:21 PM
|
#2
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
|
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.
|
|
|
05-31-2006, 09:13 PM
|
#3
|
Member
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139
Original Poster
Rep:
|
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??
|
|
|
05-31-2006, 09:28 PM
|
#4
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
|
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.
|
|
|
06-01-2006, 05:09 AM
|
#5
|
Member
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139
Original Poster
Rep:
|
whew!! thanks agen.. sorry for my stupidity.. 
|
|
|
06-05-2006, 01:30 AM
|
#6
|
Member
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139
Original Poster
Rep:
|
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..
|
|
|
All times are GMT -5. The time now is 05:34 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|