to check the job status basis on multiple pattern
Hi All,
I am writing one script to check the status of my job by checking the log file, is that completed or not ,I have one scheduler log file which i am downloading from windows server to AIX and searching the current date, job name and status code, getting issues to fix it by awk -v RS="" -v FS="\n" -v D="$(date +/%m/%d/%Y)". in the log file date is in windows format 8/29/2014 . please refer the below log file, so wanted to check for the current date abcd.job has finished successfully on the basis of completion code.if success it should give success message else failure. "abcd.job" (abcd.bat) Started 8/24/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/24/2014 5:07:04 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/24/2014 7:00:00 AM "Eventlog.job" (Event_clear.vbs) Started 8/24/2014 7:00:01 AM "Eventlog.job" (Event_clear.vbs) Finished 8/24/2014 7:00:06 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Finished 8/24/2014 7:00:09 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/25/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/25/2014 5:06:58 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/25/2014 7:00:00 AM "CRF Analysis.job" (CRF Analysis.bat) Finished 8/25/2014 7:00:08 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/26/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/26/2014 5:07:01 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/26/2014 7:00:00 AM "CRF Analysis.job" (CRF Analysis.bat) Finished 8/26/2014 7:00:08 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/27/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/27/2014 5:07:00 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/27/2014 7:00:00 AM "Eventlog.job" (Event_clear.vbs) Started 8/27/2014 7:00:02 AM "Eventlog.job" (Event_clear.vbs) Finished 8/27/2014 7:00:05 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Finished 8/27/2014 7:00:10 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/28/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/28/2014 5:07:05 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/29/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/29/2014 5:07:05 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/28/2014 7:00:00 AM "CRF Analysis.job" (CRF Analysis.bat) Finished 8/28/2014 7:00:09 AM Result: The task completed with an exit code of (0). [ ***** Most recent entry is above this line ***** ] "abcd.job" (abcd.bat) Started 8/24/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/24/2014 5:07:04 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/24/2014 7:00:00 AM "Eventlog.job" (Event_clear.vbs) Started 8/24/2014 7:00:01 AM "Eventlog.job" (Event_clear.vbs) Finished 8/24/2014 7:00:06 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Finished 8/24/2014 7:00:09 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/25/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/25/2014 5:06:58 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/25/2014 7:00:00 AM "CRF Analysis.job" (CRF Analysis.bat) Finished 8/25/2014 7:00:08 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/26/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/26/2014 5:07:01 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/26/2014 7:00:00 AM "CRF Analysis.job" (CRF Analysis.bat) Finished 8/26/2014 7:00:08 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/27/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/27/2014 5:07:00 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/27/2014 7:00:00 AM "Eventlog.job" (Event_clear.vbs) Started 8/27/2014 7:00:02 AM "Eventlog.job" (Event_clear.vbs) Finished 8/27/2014 7:00:05 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Finished 8/27/2014 7:00:10 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/28/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/28/2014 5:07:05 AM Result: The task completed with an exit code of (0). "abcd.job" (abcd.bat) Started 8/29/2014 5:00:00 AM "abcd.job" (abcd.bat) Finished 8/29/2014 5:07:05 AM Result: The task completed with an exit code of (0). "CRF Analysis.job" (CRF Analysis.bat) Started 8/28/2014 7:00:00 AM "CRF Analysis.job" (CRF Analysis.bat) Finished 8/28/2014 7:00:09 AM Result: The task completed with an exit code of (0). [ ***** Most recent entry is above this line ***** ] |
can any one help me to write my script.
|
Quote:
http://www.linuxquestions.org/questi...on-4175438073/ http://www.linuxquestions.org/questi...pt-4175440649/ http://www.linuxquestions.org/questi...pt-4175444590/ http://www.linuxquestions.org/questi...at-4175448079/ We WILL be happy to help you, but you have to post what YOU have written/tried on your own first, and tell us where you're stuck. If you want someone to write your scripts for you, then post this in the LQ Job Marketplace, along with how much you want to PAY SOMEONE to do your work, and someone will be happy to. You have been working with Linux for three years now...there are MANY scripting tutorials available, and you've been given samples before. Apply what you've learned and show some effort. |
This is what i have tried ...
awk -v RS="" -v FS="\n" -v D="$(date +/%m/%d/%Y)" but getting NIL output for every case... so wanted to check for the current date abcd.job has finished successfully on the basis of completion code.if success it should give success message else failure |
Quote:
|
sed 's/^"/\n"/' filename | awk -v RS="" -v FS="\n" -v D="$(date +/%m/%d/%Y)" -v JOB="abcd.job" 'BEGIN { gsub("/0", "/", D); D=substr(D,2); } ;
Output is NIL... So first finding the current date in file , then job name for the current date and its status (exit code),problem is in either of the case its giving NIL out put.. |
Quote:
If you want to 'debug' the line you posted, type in one command at a time, and see what the output is after each step. Personally, given the input data, I'd use grep to grab the jobs..pay particular attention to the -A and -B flags on the grep man page. That will get you the 'group' around the abcd.job lines, and you can shove that whole thing into an array, and process it accordingly. |
Thanks , As you Quated below , that is what i was looking for assistance not for complete solution..
grouping the lines into array... That will get you the 'group' around the abcd.job lines, and you can shove that whole thing into an array, and process it accordingly. |
Quote:
There are many scripting tutorials you could have easily found to show you how to do what you're after. |
This is what i have written and achieved the expected result and i was expecting a a one line snippet to sort out the the things not the entire script which is more than 100 lines and which is already written by me.
Anyway marking this thread as resolved, thanks all for your valuable time. Quote:
|
Quote:
Quote:
|
Bit crude but couldn't you just
Code:
awk '/exit code/ {if(substr($10,2,1) != 0)print}' test.Txt That should result in something (example) like this: Code:
Result: The task completed with an exit code of (127). |
All times are GMT -5. The time now is 05:42 AM. |