![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If Then Else Logic | jadionne | UNIX for Dummies Questions & Answers | 7 | 11-23-2007 04:27 AM |
| cannot get the logic | dineshr85 | Shell Programming and Scripting | 3 | 10-11-2007 07:34 AM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 10:52 PM |
| Automated FTP to variable directory with error check | songtam | UNIX for Dummies Questions & Answers | 3 | 04-10-2006 09:57 AM |
| Status check of Automated FTP | anijog | Shell Programming and Scripting | 5 | 03-04-2004 02:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Need logic for check automated Job work in awk or SED.
I have a Java program which will automatically trigger some scheduled job to update Db or some other work. I am tracking the jobs with log messages and finding out it is properly run or not. I want to write a script to capture it correctly on time.
Say Job1 is running on 15, 30, and 45 every hour then it leave an entry in the log file that “JOB1 is started”. Like this. Example for hour 11:00 pm means – Worker#Scheduler_Worker-3: 23:15:56 105 SendToCM: run() Entry where “SendToCM: run() Entry” starting log message which Java program write in the log message, '23:15:56' is the time . I need to check the last hour 15 , 30, 45 min log files to find out the entry is their or not then I intimate via mail to me. i have a logic but not tested yet. For 15 min I am checking with sed like this, sed -n "/: $h:15:00/,/: $h:15:01/p" schedulerTrace .log > Job1.log here $h contains the current hour and in the job1.log I’m checking again like count=grep –c “SendToCM: run() Entry” Job1.log. if count is zero then the JOB1 is not ran and I need to check exception. But this logic is very oblique to me. Could you me please help me on finding out a correct logic for this. Regards, Senthilkumar. |
|
||||
|
Why not ignore the seconds component completely and just do something like:
Code:
if grep -q ": $h:15.*SendToCM: run()" schedulerTrace.log
then
echo job did run
else
echo job did not run
fi
Last edited by Annihilannic; 09-01-2008 at 02:46 AM.. Reason: forgot the SendToCm part |
|
||||
|
So... you want to only run your check once an hour and see whether it has run three times?
Code:
if [[ "$(grep -Eqc ": $h:(15|30|45):.*SendToCM: run\(\)" schedulerTrace.log)" -eq 3 ]]
then
echo job did run 3 times in the hour
else
echo job did not run 3 times in the hour
fi
|
|
||||
|
Well yes you're right, the log files contains only one day logs. But with this condition i wont be check the job when not ran, so i modified little and used like this , please let me know if done some thing wrong.
# Loop to check the Job1 <Send To CM started properly or not> if [ $min -ge 1 -o $min -lt 30 ]; then count=`grep -ic ": $hr:01.*SendToCM: Start:" $logpath` elif [ $min -ge 30 -o $min -le 59 ]; then count=`grep -ic ": $hr:30.*SendToCM: Start:" $logpath` fi if [ $count -eq 0 ]; then echo -e "\nThe Job1 Send To CM is not started as schdueld at 1 and 30" >> mail.log fi i will mail the mail.log at last after checking for other jobs too |
|
||||
|
I see nothing obviously wrong there.
|
| Sponsored Links | ||
|
|