Re: [CentOS] Unable to grep 5 mins logs

2011-06-14 Thread ankush grover
>> >> It is really slow when 2-3 greps are combined. >> > > But it will do the job until you solve this with more elegance. > > What you can try is to compile search pattern from 2-3 date outputs so > it will match the text in the log. > > > dayname="$(date "+%a")"; month="$(date "+%b")"; time="$(d

Re: [CentOS] Unable to grep 5 mins logs

2011-06-13 Thread Ljubomir Ljubojevic
ankush grover wrote: > Combine 2-3 greps: >> for (( i = 5; i>=0; i-- )) ; do grep `date "+%a"` | grep `date "+%b"` | >> grep `date "+%d"` | grep `date "+%Y"` | $(date "+%R" -d "-$i >> min") /var/ossec/logs/active-responses.log>> /tmp/newlog.log;done >> >> Change order of greps to gain speed at fir

Re: [CentOS] Unable to grep 5 mins logs

2011-06-13 Thread ankush grover
Combine 2-3 greps: > > for (( i = 5; i>=0; i-- )) ; do grep `date "+%a"` | grep `date "+%b"` | > grep `date "+%d"` | grep `date "+%Y"` | $(date "+%R" -d "-$i > min") /var/ossec/logs/active-responses.log>>  /tmp/newlog.log;done > > Change order of greps to gain speed at first cutting part of lines w

Re: [CentOS] Unable to grep 5 mins logs

2011-06-13 Thread Ljubomir Ljubojevic
John R Pierce wrote: > On 06/13/11 12:36 AM, ankush grover wrote: >> Hi Friends! >> >> I need to prepare a script which will grep logs from the current time >> to previous 5 mins that is if the current time is Mon Jun 13 12:40:40 >> IST 2011 then all the logs between the interval Mon Jun 12:35 - 12

Re: [CentOS] Unable to grep 5 mins logs

2011-06-13 Thread John R Pierce
On 06/13/11 12:36 AM, ankush grover wrote: > Hi Friends! > > I need to prepare a script which will grep logs from the current time > to previous 5 mins that is if the current time is Mon Jun 13 12:40:40 > IST 2011 then all the logs between the interval Mon Jun 12:35 - 12:40 > 2011 should be grepped

[CentOS] Unable to grep 5 mins logs

2011-06-13 Thread ankush grover
Hi Friends! I need to prepare a script which will grep logs from the current time to previous 5 mins that is if the current time is Mon Jun 13 12:40:40 IST 2011 then all the logs between the interval Mon Jun 12:35 - 12:40 2011 should be grepped by the script and append it to another file. However,