Sponsored Content
Full Discussion: Script to read log file
Top Forums UNIX for Advanced & Expert Users Script to read log file Post 302603520 by Paulwintech on Thursday 1st of March 2012 07:59:25 AM
Old 03-01-2012
Script to read log file

Hi,

Im looking for a shell script which will search for a particular string in a log file as below scenario

1. I need to run URL http://localhost/client/update?feedid=200 in shell script at(eg)4:00 PM which will not take more than 15 mins to complete.

2. After 15 mins i need to check the log from 4:00 PM to 4:15 PM.

3. Need to check logs file for 2 strings (a) Feed id=200 (b) Item=Product example, if these 2 string matches i need to check for "Error" string.

4. If 3 string matches i will send a mail stating "Failed"

5. If string "Error" is not found in last 15 mins log(only string a & b should match) then i will execute another 6 URLS and atlast will trigger mail stating "Success"

6. Is this above sequence possible in shell script? Please guide me and my script is below - Im really stuck in comparing string and checking last 15 mins log.

7. Log with Error
Code:
[INFO 12-03-01:04:10:25] Starting FeedRunner for feed: 200  Product example Items 
[INFO 12-03-01:04:12:40] Error FeedRunner for feed: 200 Product example Items
[INFO 12-03-01:04:20:25] Stopping FeedRunner for feed : 200  Product example Items Feed time taken 231743

8. Log without Error
Code:
[INFO 12-03-01:04:10:25] Starting FeedRunner for feed: 200  Product example Items 
[INFO 12-03-01:04:20:25] Stopping FeedRunner for feed : 200  Product example Items Feed time taken 2743

9. Script
Code:
#!/bin/sh

START=$(date +"%y-%m-%d:%T")
echo $START
curl "http://localhost/mcfeeds/runfeed?feedid=200"
END=$(date "%y-%m-%d:%T")
echo $END

cat /path/logfile.log | sed -n '/$START/,/$END/ p' > output.txt

grep '200'&'Product example'&'Error' output.txt

Thanks
Paulwintech

Last edited by Paulwintech; 03-02-2012 at 03:03 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read a specific value from a Log file?

Hi, I have a .log file in which it has many values. But i need some specific values. How it can be done using Shell Script. Please explain in detail. Thankx in advance. Sathish D V. (8 Replies)
Discussion started by: cooolthud
8 Replies

2. Shell Programming and Scripting

Shell script to read multiple log files

Hi all, I have to generate some report from shell script .We have stacktrace log file which generate hourly basis. So now my q is that how this shell script will read all stacktrace log file for particlular day and parse accordingly desire output. Any help or suggestion as i am newbie with... (1 Reply)
Discussion started by: esungoe
1 Replies

3. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

4. Solaris

Read zipped log file

If we have a big zipped log file, how can we look for a specific string in this zipped log file without unzipping it? Thanks, (2 Replies)
Discussion started by: Pouchie1
2 Replies

5. Shell Programming and Scripting

Help w/ script to read file and parse log message

Hi, I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***... The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE. Can anyone give help? Thanks (2 Replies)
Discussion started by: shyork2001
2 Replies

6. Shell Programming and Scripting

Unix script help to read log file

Hi I have a big log file :08,936 DEBUG HttpConnectionManager.getConnection: config = 11:39:08,936 DEBUG Getting free connection, 11:39:08,989 DEBUG Freeing connection, hostConfig=HostConfiguration 11:39:08,989 DEBUG Notifying no-one, there are no waiting threads 11:39:09,046... (4 Replies)
Discussion started by: javaholics
4 Replies

7. Shell Programming and Scripting

Read from Log file in Ksh

I have a log file like.. IMPORT from /dataserver/ftp/bits/mdr/mdr_data_discon.dat OF DEL ..... Number of rows read = 1376 Number of rows skipped = 0 Number of rows inserted = 1374 Number of rows updated = 0 Number of rows rejected = 2 Number of rows... (4 Replies)
Discussion started by: ramse8pc
4 Replies

8. Shell Programming and Scripting

script to constantly read the last 500 new logs in a log file

Hello, I would like to write a bash script that would monitor a log file for a certain number of logs, let's say 500 logs and when it reaches that number to write the last log to another file. For example, I want to watch the /var/adm/messages and everytime, there is 500 new logs that are... (1 Reply)
Discussion started by: Pouchie1
1 Replies

9. Shell Programming and Scripting

HELP: Shell Script to read a Log file line by line and extract Info based on KEYWORDS matching

I have a LOG file which looks like this Import started at: Mon Jul 23 02:13:01 EDT 2012 Initialization completed in 2.146 seconds. -------------------------------------------------------------------------------- -- Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies

10. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies
POPPASSD(8)															       POPPASSD(8)

NAME
poppassd - Password change server for Eudora and NUPOP mail clients DESCRIPTION
poppassd runs from inetd and listens on TCP port 106 by default. Its sole purpose in life is to engage in short FTP-like conversations from client applications and execute (or deny) remote password changes via the PAM facilities configured in /etc/pam.d/poppassd. The con- versation looks something like this: 200 poppassd v1.8.4 hello, who are you? user adconrad 200 Your password please. pass foo 200 Your new password please. newpass bar 200 Password changed, thank-you. quit 200 Bye. As can be seen from the example above, unencrypted passwords are transmitted over the network. Because of this, it is recommended that you use this daemon only for local loopback password changing (for instance, from Perl, Python, or PHP web applications on the same server) and block all non-local access to port 106, either via tcpwrappers (/etc/hosts.deny) or with appropriate firewall rules. If sending unencrypted passwords over the wire doesn't bug you terribly much (as in the case of an ISP with hundreds of POP3 mail accounts), this daemon can provide a simple way for some of your clients (those running mail clients that actually support this protocol) to easily change their passwords. FILES
/etc/pam.d/poppassd Contains the PAM configuration for poppassd. By default on Debian, it merely includes the common-auth and common-password files, which should work in most cases. If this doesn't cut it for your site, tailor to suit. SEE ALSO
pam(7), inetd(8), hosts.deny(5) AUTHOR
This manual page was written by Adam Conrad <adconrad@0c3.net> for the Debian operating system. Debian 19 March 2004 POPPASSD(8)
All times are GMT -4. The time now is 05:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy