Shell script is hanging up every time even after it's successful

We are using a korn shell script which is meant to trigger a Oracle job to load the data from a flat file to an Oracle database . Also the same script addresses the following tasks also like triggering a SFTP job to pick the file from one path to the target location and checking the same with control file to validate the control file and finally it triggers an email on success and failure of the jobs.

But everytime even after successful completion ,it's hanging up everytime and we need to exit the script forcefully by using ctrl c command though it has exit 0 at end of the script.

Hi
There are probably commands in the script running in the subshell. Try adding the wait command at the end

1 Like

Set xtrace and verbose ON and run the script to understand at which stage it is waiting.

#!/bin/ksh -xv

Just adding wait will work?

wait
exit 0
1 Like

I think the wait only waits for its background commands (fired with & )
More promising is to run the script with ksh -x and watch what it does.
Another quick shot is to run it with < /dev/null

Hi - Where can we give? the < /dev/null(exit suppresss exit status command) in my code ? also what's the difference between ksh -x and ksh -xv while debugging the code?

ksh -v shows the original shell code as it gets processed.
ksh -x shows the code after all substitutions were done.
ksh -x -v or ksh -xv shows both.

</dev/null redirects the input. In case something in the script unwantedly reads from (and waits for) input, the /dev/null inputs nothing, and the script continues.
How do you run your script, what is the command that runs it? Just add a </dev/null

1 Like
Moderator comments were removed during original forum migration.