Need help to search strings every 15 minutes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help to search strings every 15 minutes
Prev   Next
# 1  
Old 06-08-2017
Need help to search strings every 15 minutes

I have written a script which will search logfiles directory particular two strings and send a message to user to kill the process id if string found every 15 minutes

Note::dont have cron tab access(Auto run every 15 minute)

oS--AIX

Please add script search the PID into logfile "My PID is: 123456" and kill that process ID
Please find the attached sample files
Code:
#!/usr/bin/ksh                                                                            
while true
do
day=`date +%a`
time=`date +%H%M`
str1 = "bad Parm"
str2 = "wrong parm"
cd sri
if [  $day = "Mon" -o $day = "Tue" -o $day = "Wed" -o $day = "Thu" -o $day = "Fri" ] ;
then
        if [ $time -gt 0700 -a $time -le 0900 ]; then
           grep -e "$str1" -e "$str2" *.log
           mail -s "Alert" "sri123@gmail.com"
        else
           echo "Exit successfully"            

        fi
done


below is the sample of
*.log file contains

Code:
 Server mapping to server section and picking a place to call home...
   . . . mapped . . .
   . . . looking for domain . . .
   . . . Found domain & got the lock; now looking for a free slot . . .
   . . . looking . . .
   . . . looking . . .
   . . . looking . . .
   . . . Found one and I'm taking it!  Now let go of the lock . 

* Immediate sarting .  My PID is: 123456


bad parm. (GET:DATE)
bad parm. (GET:DATE)
bad parm. (GET:DATE)

date can't be a correct date

wrong parm. (NEXT.date)
wrong parm. (NEXT.date)
wrong parm. (NEXT.date)


Last edited by Scrutinizer; 06-08-2017 at 11:33 AM.. Reason: code tags also for data
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep a log file for the last 5 minutes of contents every 5 minutes

Hi all, System Ubuntu 16.04.3 LTS i have the following log INFO 2019-02-07 15:13:31,099 module.py:700] default: "POST /join/8550614e-3e94-4fa5-9ab2-135eefa69c1b HTTP/1.0" 500 2042 INFO 2019-02-07 15:13:31,569 module.py:700] default: "POST /join/6cb9c452-dcb1-45f3-bcca-e33f5d450105... (15 Replies)
Discussion started by: charli1
15 Replies

2. UNIX for Beginners Questions & Answers

How to convert days hours minutes seconds to minutes?

Hi, please help with below time conversion to minutes. one column values: 2 minutes 16 seconds 420 msec 43 seconds 750 msec 0 days 3 hours 29 minutes 58 seconds 480 msec 11 seconds 150 msec I need output in minutes(total elapsed time in minutes) (2 Replies)
Discussion started by: ramu.badugula
2 Replies

3. Shell Programming and Scripting

Script to search for a pattern in 30 minutes from a log file

Hello All, I have to write a script which will search for diffrent patterns like "Struck" "Out of Memory" , etc from a log file in Linux box's. Now I will be executing a cron job to find out the results by executing the script once in every 30 minutes. suppose time is 14-04-29:05:31:09 So I... (3 Replies)
Discussion started by: Shubhasis Mathr
3 Replies

4. Shell Programming and Scripting

Search between two search strings and print the value

Based on the forums i have tried with grep command but i am unable to get the required output. search this value /*------ If that is found then search for temp_vul and print and also search until /*------- and print new_vul Input file contains: ... (5 Replies)
Discussion started by: onesuri
5 Replies

5. Shell Programming and Scripting

Search between 2 strings

Guys any pointers on how to search between 2 sets date strings with time in the below file example :- 02-Feb-2010 23:12:09 GMT event_type::event_details_are_like_this 02-Feb-2010 09:10:29 GMT event_type::event_details_are_like_this 03-Feb-2010 11:12:19 GMT... (3 Replies)
Discussion started by: lavascript
3 Replies

6. Shell Programming and Scripting

How can i search a file which has been created or modified in last five minutes

Hi Can some one please help me How can i search a file which has been created or modified in last five minutes I have used the command find . -mmin -5 and it does not work i get an error -mmin is bad option Please help Much regards Tarun (2 Replies)
Discussion started by: tarundeepdhawan
2 Replies

7. Shell Programming and Scripting

how to search with 2 strings.

Hi, i have a file a.txt like -------------------------------- col1|col2|col3 data1|data2|data3 other1|other2|other3 -------------------------------- i need to search 2 strings(data in a.txt file is case sesnsitive), suppose data1 and data2. If these 2 strings found then only i need... (2 Replies)
Discussion started by: syamkp
2 Replies

8. Shell Programming and Scripting

Search between strings with an OR

Hi have Input in this way KEY AAAA BBBB END1 KEY AAAA BBBB END2 KEY AAAA BBBB END3 I need to find any thing matching in between KEY And ending with "END1|END2|END3" This didnot work awk '/KEY/,/END1|END2|END3/' (3 Replies)
Discussion started by: pbsrinivas
3 Replies

9. Shell Programming and Scripting

Convert minutes to hours, minutes, seconds

How would you convert lets say a 1000 minutes to hours, minutes, seconds (1 Reply)
Discussion started by: Vozx
1 Replies

10. UNIX for Dummies Questions & Answers

Search for strings

I am trying to replace the word ACTIVE with 2002 in a file and I am getting the following error. Does anyone know what this means? $ sed "s/ACTIVE/2002" mydata.txt > yourdata.txt sed: 0602-404 Function s/ACTIVE/2002 cannot be parsed. (5 Replies)
Discussion started by: lesstjm
5 Replies
Login or Register to Ask a Question