Terminate shell script if stored proc fails, to capture status in my autosys job - shell

I have Korn script that executes my SQL stored proc. My Autosys job invokes this script. I want to capture the status of the stored proc in my autosys job. Right now even if my stored proc fails, autosys captures success since the shell script succeeds(i can capture teh error in script but the script it self doesn't fail). How do i fail the script if my stored proc fails and therefore fail the autosys job.

Exit with a non-zero return code, e.g.
exit 1

Related

bash: stop subshell script marked as failed if one step exits with an error

I am running a script through the SLURM job scheduler on HPC.
I am invoking a subshell script through a master script.
The subshell script contains several steps. One step in the script sometimes fails because of the quality of the data; this step is not required for further steps, but if this step fails, my whole subshell script is marked with "failed" Status in the job scheduler. However, I need this subshell script to have a "completed" Status in the Job scheduler as it is dependency in my master script.
I tried setting up
set +e
in my subshell script right before the optional step, but it doesn't seem to work: I still get an exitCode with errors and FAILED status inthe job scheduler.
In short: I need the subshell script to have Status "completed" in the job scheduler, no matter whether one particular step is finished with errors or not. Will appreciate help with this.
For Slurm jobs submitted with sbatch, the job exit code is taken to be the return code of the submission script itself. The return code of a Bash script is that of the last command in the script.
So if you just end your script with exit 0, Slurm should consider it COMPLETED no matter what.

How to avoid series of commands running under sql plus using shell script

I have created a script which runs a series of other instances in shell using the while command. But the problem is that one of the job is connecting to sql plus and running the remaining command under sqlplus.
For ex. my input file --> job.txt
job1
job2
job3
Now, using the below script I am calling job one by one. So, until the present job is finished next job wont start. But the catch comes when the job tries to connect the sql plus. After it connects to sql plus, the process id of the current job gets complete and remaining jobs run as the sql statement in unix env.
while read line;
do
$job1
done < job.txt;
Error message I am getting in sqlplus after current instance exits.
SP2-0042: unknown command
How can I avoid bringing the jobs under sqlplus.

Shell Script executing Oracle PL/SQL code

I'm calling a PL/SQL code from shell script which takes time to finish, but after completion of PL/SQL code the shell script session is not terminated and also still shows as active when is type ps -aef|grep 'SQL*PLUS'. Any suggestion why the shell script session is not terminated.
Note : PL/SQL code has no issue and ran successfully. I have used cron job to run the shell script.
The shell script is terminated when Data is less to process.

Autosys job not failing when the shell script fails

I am moving existing manual shell scripts to execute via autosys jobs. However, after adding exit 1 for each failed autosys job; it is not failing and autosys shows exit code as 0.
I tried the below simple script
#!/bin/ksh
exit 1;
When I execute this, the autosys job shows a success status.I have not updated success code or max success code in autosys, everything is default. What am I missing?

Autosys Job failing due to underlying script not being exited

I have an Autosys Job, which calls a wrapper script, which in turn calls a script which starts up a server and keeps running.
Now the problem i am facing is that once the job starts , it keeps on waiting for the exit signal or script to exit, but being unable to find so sends the job into a FAILED state.
Can anyone provide a workaround for this?
For demo :
lets say i have autosys job :A
wrapper script as : W.sh
Main restart script : serverrestart.sh
A
|---W.sh
|---serverrestart.sh ( Always running )

Resources