Schedule script is not executing some times

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Schedule script is not executing some times
# 1  
Old 05-21-2012
Schedule script is not executing some times

Dear Experts,

Once again i need your vital help to fix my issue, please do the needfull.

Issue:- I have schedule one script on windows server to run's every 10 min.(Script do check the alert log file,if database found down it send the email) While i'm doing the database down manually its sending email,
But when its automatically down (By some issue) its not sending the email, I beleive some thing worng in my schedule task, schedule screen shot attached pls help.

Thanks in Advance.
Mohammed Fareed
# 2  
Old 05-21-2012
where is your script and what pattern you are checking in the logs ?

Is the same log pattern or error is coming in logs (when you manually shutdown and it crashes ? )
# 3  
Old 05-21-2012
Thanks for helping me again Kamaraj, whenever database shutdown or crashes, we have massage in alertlog like "shutdown" and script look for this last fewlines if it is matches send the email. hope you understood my senario.
Mohammed Fareed
# 4  
Old 05-21-2012
script look for this last fewlines -- if the shutdown pattern is not in the last few lines ( eventhough the DB is crashed ? )

howmany lines you are checking ?
# 5  
Old 05-21-2012
Thanks for update, i checked in alert log if the database crash its dazen appear the "shutdown" word, Hence I need to add in code extra word "terminated instance".

Can you please help me into this how do i add the extra text in my code?
bold in existing code.

Code:
 
dim WshShell
dim f,fso,Filename
Dim arrFileLines() 
Const ForReading = 1
i = 0 
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.OpenTextFile("C:\\blat182_b\alert.log", 1) 
' create the output file here 
Set objoutputFile = FSO.CreateTextFile("C:\\blat182_b\result_new.txt") 
Do Until objFile.AtEndOfStream 
Redim Preserve arrFileLines(i) 
arrFileLines(i) = objFile.ReadLine 
i = i + 1 
Loop 
objFile.Close 
For l = Ubound(arrFileLines)-5 to Ubound(arrFileLines) 
' write the output to the file 
objoutputFile.writeline arrFileLines(l) 
Next 
'Close the output file 
objoutputFile.close 
Filename = "C:\\blat182_b\result_new.txt"
Set f = fso.OpenTextFile(FileName, ForReading, True)
FileText = f.ReadAll
f.close
IF InStr(FileText,"shutdown", "Instance terminated") Then
 'Trigger the email - use blat or bmail utility
 Set WshShell = WScript.CreateObject("WScript.Shell")
 WshShell.Run "C:\\blat182_b\\mailsend -d xxxx.local -smtp xxx.xxx.xxx.xxx -t xxxx@xx.com, -c xxxx@xx.com  -f xx@xxx-xx.xx -sub ""Critical Alert  Database not running"" -m message.txt", 1, True
 'clear out wshshell variable
 set wshShell = Nothing
END IF
WScript.Quit


Last edited by Scrutinizer; 05-21-2012 at 06:37 AM.. Reason: code tags instead of quote tags, removed email tags because of that...
Mohammed Fareed
# 6  
Old 05-21-2012
Code:
IF InStr(FileText,"shutdown") or Instr(FileText,"shutdown") Then

# 7  
Old 05-21-2012
I want to check two clause one is
PHP Code:
shutdown 
and another is
PHP Code:
terminated instace
in my above code its not working...
Mohammed Fareed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Script is not executing as expected when I schedule it in cron

Hi, I have a shell script which fetches the MRP status and the LAG status. When I execute it manually like, sh <script_name>, it fetches the output as expected, but when I schedule through crontab, it's not working as expected. Any help would be really appreciated. Here is the code... (3 Replies)
Discussion started by: Nagaraj R
3 Replies

2. UNIX for Dummies Questions & Answers

Schedule the Script

I have wriiten one script to get some results from log files. Daily I have to run the script using the below command to get the output. What I need is, Can I schedule the Script to execute once every day at a particular Time and get the output by mail automatically? I heard about 'cron job' . .... (3 Replies)
Discussion started by: Padmanabhan
3 Replies

3. Shell Programming and Scripting

Schedule tasks in shell script

shell=ksh, How could I schedule tasks in shell script INSTEAD OF using the crontab -e functionality? For example, I want a script to print "Hello World" every 10 seconds (i.e., INTERVAL = 10s) until external termination signal is triggered. Thanks, (2 Replies)
Discussion started by: isaacniu
2 Replies

4. Shell Programming and Scripting

Cron to schedule job at different times

Hi, I want to run cron scheduler to run some script at different times of the day.But these times don't have some fix intervals. So how we can run jobs at 6:30AM, 1:00PM and 4:30PM everyday. Please help. Thanks Neeraj (2 Replies)
Discussion started by: apjneeraj
2 Replies

5. UNIX for Dummies Questions & Answers

Best way to schedule script to run Ubuntu 10.04

On Ubuntu 10.04 LTS, I would like to know the best way to schedule myscript.sh to run at a specified time, please provide examples and specify things like does cron have to be running, how do I check if cron is running and all that. I have tried unsuccessfully in the past to run the AT command,... (1 Reply)
Discussion started by: glev2005
1 Replies

6. Shell Programming and Scripting

How to schedule a script in crontab.

Hi, My script is in $home/bin/sample.sh. I want to run the script for 3times a day, first execution will be at 08:00 am. second execution will be at 16:00 pm third will be at 23:59 pm. what will be the entry with this requirement?? (1 Reply)
Discussion started by: shrima.pratima
1 Replies

7. Shell Programming and Scripting

How to schedule my script without crontab

I have a script which shoud run after every 30 minutes.Though I know abt crontab, unfortunately I dont have access/authorization to use crontab in my terminal. Could any one pls let me know how to schedule the script without crontab ? Regards Prashant:) (3 Replies)
Discussion started by: prashant43
3 Replies

8. Shell Programming and Scripting

Script Schedule Scrutiny

Hi All, Here's one that may belong in the Scripting Thread but I thought I'd start off here. Here's the scenario:- I have to transfer the functionality and data from an old E450 to a nice new Sun V440. The E450 contains a bunch of scripts which may or may not still be in use daily,... (2 Replies)
Discussion started by: geralex2
2 Replies

9. Shell Programming and Scripting

Schedule a script to check mail?

Hi, I'd like to somehow schedule a task on my webserver, such that my account's mail is checked every 10-15 minutes and: a) any new e-mails received from a particular address are POST-ed to a PHP webpage on my server. b) any new e-mails received from a different particular address are... (2 Replies)
Discussion started by: stujones
2 Replies

10. Shell Programming and Scripting

How can I schedule a script on Solaris?

How can I schedule a script on Solaris? (3 Replies)
Discussion started by: krikets
3 Replies
Login or Register to Ask a Question