dsjob has status=0 even though job aborts
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 9
- Joined: Fri May 29, 2009 9:23 am
dsjob has status=0 even though job aborts
I have a sequence job that includes an exception handler that emails if any job aborts. This works fine. However when I run the run from the command line using dsjob the exit code is always 0 whether an error occurred or not. I get the email when an error occurs, but how can I set the exit code so that I can trap it from my Unix script?
I created an error in a parallel job and ran the sequence job below. I received an error email.
dsjob -run -wait myproj myjob
Waiting for job...
Finished waiting for job
Status code = 0
> echo $?
0
I created an error in a parallel job and ran the sequence job below. I received an error email.
dsjob -run -wait myproj myjob
Waiting for job...
Finished waiting for job
Status code = 0
> echo $?
0
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The status of dsjob was correctly 0. It (the dsjob command itself) completed successfully.
If you want the status of dsjob to be the status of the job itself, then you must use the -jobstatus option rather than the -wait option.
If you want the status of dsjob to be the status of the job itself, then you must use the -jobstatus option rather than the -wait option.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 106
- Joined: Thu Jun 08, 2006 8:51 am
My statements have been based on my assumption that their Sequence job is always running to completion 'without error' and the errors mentioned are when jobs under the control of the Sequence fail. I don't believe the Sequence itself is failing, in other words.ray.wurlod wrote:Not true. If the job aborts they get 3. If it finishes with warnings they get 2. If they used -mode RESET they get 21. And so on.
We shall see. [shrug]
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 9
- Joined: Fri May 29, 2009 9:23 am
Regretfully I do not have premium access so I cannot see your answer.... I added a terminator_activity after the email, but the seq job still returns exit code 0.
I tried setting -jobstatus on the dsjob command line, but that returned 1 (job finished OK) instead of 0 for jobs that completed.
I tried setting -jobstatus on the dsjob command line, but that returned 1 (job finished OK) instead of 0 for jobs that completed.
ray.wurlod wrote:The status of dsjob was correctly 0. It (the dsjob command itself) completed successfully.
If you want the status of dsjob to be the status of the job itself, then you must us ...
-
- Participant
- Posts: 9
- Joined: Fri May 29, 2009 9:23 am
One of the parallel jobs called by the seq job is aborting. I added a separate "exception handler"-->"notification activity"-->"terminator_activity" to the seq job to try and trap the abort, email me and (hopefully) return an exit code other than zero. So basically the seq job looks like:
"job1"-->"job2"-->"job3"-->"job_last"
"excp"-->"email"-->"term"
Job3 is aborting which triggers the excp.
"job1"-->"job2"-->"job3"-->"job_last"
"excp"-->"email"-->"term"
Job3 is aborting which triggers the excp.
chulett wrote:Clarify what is aborting here - the Sequence job itself, job(s) it is running or both? If the Sequence job aborts and you are using -jobstatus you will get a 3 rather than a 1. ...
-
- Participant
- Posts: 9
- Joined: Fri May 29, 2009 9:23 am
In the log in the Director I see:
Starting my_seq_job
Waiting for Job1 to start; Waiting for Job1 to finish
Job1 as finished, status=1 (Finished OK)
Waiting for Job2 to start; Waiting for Job2 to finish
Job2 as finished, status=1 (Finished OK)
Waiting for Job3 to start; Waiting for Job3 to finish
Job3 has finished, status=3 (aborted)
Executing Exception_Handler
Sent message to {my_email}
(fatal error from Terminator_activity) Sequence abort requested
Job my_seq_job aborted
Starting my_seq_job
Waiting for Job1 to start; Waiting for Job1 to finish
Job1 as finished, status=1 (Finished OK)
Waiting for Job2 to start; Waiting for Job2 to finish
Job2 as finished, status=1 (Finished OK)
Waiting for Job3 to start; Waiting for Job3 to finish
Job3 has finished, status=3 (aborted)
Executing Exception_Handler
Sent message to {my_email}
(fatal error from Terminator_activity) Sequence abort requested
Job my_seq_job aborted
chulett wrote:Didn't quite answer the question. Does the Sequence job itself abort? That's the crux of the issue and something the Terminator should be doing for you. ...
OK, good - now the Sequence is aborting as well and will return an exit status of "3" when using the -jobstatus option. If that's not what is happening, make sure you are using it by itself and not in conjunction with the -wait option - it's one or the other.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 9
- Joined: Fri May 29, 2009 9:23 am
OK, I just tried it and I get a '3' exit code. When I fixed the error I get a '1' exit code - and not the standard '0' for good. I can live with this and program the script accordingly. So there is not a way to return standard exit codes of '0' for good and non-zero for bad? I assume I'll have to check for 1 for OK, 2 for warnings and 3 for abort? 1,2=good, anything else=bad.
chulett wrote:OK, good - now the Sequence is aborting as well and will return an exit status of "3" when using the -jobstatus option. If that's not what is happening, make sure you are using it by itself and not in conjunction with the -wait option - it's one or the other.