Re: grep with actual date ?
Oliver Schoenknecht said:
> I am planning to do a daily system check with refused connects by
> placing them in a cron job. So far, so good. But - and that's the
> problem - does anyone know how to tell the "grep"-command to
> filter just the refused connects of today and not all those which are
> two weeks old ? This should happen each day frequently so any
> help would be appreciated very well...
I agree with the earlier poster that it'd be better to use a script for
real(ish)-time monitoring and/or install the logrotate package to break up
your logs by day (e.g., /var/log/messages is always today,
/var/log/messages.0 is always yesterday, etc.), but...
grep "$(date +"%b %d")" filename
will return all entries which include today's date. From there, you'll just
need to build up the grep expression to filter it down to the messages that
interest you.
--
"Two words: Windows survives." - Craig Mundie, Microsoft senior strategist
"So does syphillis. Good thing we have penicillin." - Matthew Alton
Geek Code 3.1: GCS d- s+: a- C++ UL++$ P+>+++ L++>++++ E- W--(++) N+ o+ !K
w---$ O M- !V PS+ PE Y+ PGP t 5++ X+ R++ tv- b++ DI++++ D G e* h+ r++ y+
Reply to: