Search and email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search and email
# 8  
Old 07-18-2012
Bug

Quote:
Originally Posted by manju98458
Due to security issue , I cannt able to paste the logs please
Assuming your log files generated with timestamps and log file is updated continuously..
log file sample-
Code:
2012-07-18 09:04:03,428  
2012-07-18 09:04:14,706  
2012-07-18 09:04:28,766  
2012-07-18 09:04:33,293  
2012-07-18 09:04:44,135  
2012-07-18 09:04:55,203

Now we need to get 3 hours old time stamp.. this is as per the time stamp from log file
Code:
var_date=`date --date="3 hours ago" +%Y-%m-%d_%H:%M | sed 's/_/ /g'`
echo $var_date
2012-07-18 06:15

Now to search data for the 3 hours of span ..

Code:
cat file.log | sed '1,/'$var_date'/d'

now you can grep what you want..

pamu..Smilie

Last edited by pamu; 07-19-2012 at 02:50 AM..
# 9  
Old 07-19-2012
Hi Pamu,

Thanks for your eg. but i have tried with string, still haven't got success

can you please give the eg with string option.
# 10  
Old 07-20-2012
you just try tail....
You can find how many lines may logged in log file for 3 hours and just tail that file..
assuming in 3 hours 10000 lines are recorded...

just use.

Code:
tail -10000 file.log

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Search email addresses using grep command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Let's say if we have a file with a lot of information. For example: iiadam otterhedgehog kayleigh... (2 Replies)
Discussion started by: ForeignGuy
2 Replies

2. Shell Programming and Scripting

Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping my code ( echo "From: $FROM" echo "To: $MAILTO" echo "CC: $CC" echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed;... (6 Replies)
Discussion started by: mirwasim
6 Replies

3. UNIX for Dummies Questions & Answers

Search string and send email

Hi All, I need script which should search for the "reason code" and it should send mail with its preceding line as well as the line below it.(first line before it and line after it) I used below script but it is printing the whole lines inside it, your help is appreciated: cd... (3 Replies)
Discussion started by: rockingvj
3 Replies

4. Shell Programming and Scripting

Awk to search for sting in lines and then email.

I'm trying to use awk in a script to search for a string number in a plist file. basically its a plist that records the bandwidth usage, and if the number is greater than 3GB which is equals 3221225472 bytes, it will send me an alert by email. here is the file: =<?xml version="1.0"... (4 Replies)
Discussion started by: ivaldiz
4 Replies

5. Shell Programming and Scripting

search file for value greater than 'n' on each line and email

Hi, I need to write a script that will read each line of a CSV file, look for values greater than x seconds and email an alert. For the first part, I have one CSV per day, each line in the CSV has comma separated values. There are a total of 8 fields per line separated by commas. 6th and 7th... (3 Replies)
Discussion started by: ssid
3 Replies

6. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

7. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

8. Solaris

Send an email from Solaris using Linux email server

Hello everyone I have a problem and I need your help: I have a Solaris 10 and Solaris 8 UNIX Servers, and Linux Centos4 as email server. I need send an email from Solaris servers preferably using Centos4 email server. I have no mail service configured in my Solaris computers (1 Reply)
Discussion started by: aflores
1 Replies

9. Forum Support Area for Unregistered Users & Account Problems

Changed email, now I can't post/search

I decided to change my email address to the one I have at work and now I cannot post or search. I'm guessing that there is a confirmation email that was sent that may have been blocked by the mail server. Can you tell me of a way to change my email address back to my personal one now that I... (1 Reply)
Discussion started by: douknownam
1 Replies

10. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question