Korn shell. wait command and crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Korn shell. wait command and crontab
# 1  
Old 09-11-2012
Korn shell. wait command and crontab

I have the following ksh script:
Code:
sqlplus usr1/pw1@DB1 @$DIR/a.sql $1 &
sqlplus usr2/pw2@DB2 @$DIR/b.sql $1 &
wait
echo "Done!"

Where $DIR is a variable with the absolute path where a.sql and b.sql are.

For some time, I've been running this script daily and it works fine. The intentions is that both SQL*Plus sessions go to the background and execute in parallel, and when they finish I can continue with the following steps of the application.

Since it's not a test version anymore, I scheduled it on the crontab to execute daily. The problem I have now is that it wont pause on "wait" and let the sqlplus sessions finish, but it directly outputs "Done!". In the real app, that "echo Done!" is actually a call to another program to do some processing on a.sql's and b.sql's output. But since it's not waiting for both sql scripts to actually finish, the processing cannot be done.

It works absolutely perfect when I run it myself, wether I do it from the local directory or from the root (as crontab would do it). But when it is executed automatically by the crontab, I't doesn't stop at wait and screws the whole thing up.

Any ideas on what might be happening? Thanks!

Last edited by Franklin52; 09-12-2012 at 03:36 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 09-12-2012
Does your script start with #!/bin/ksh in the first line? If not, insert it and see, if it makes any difference.
# 3  
Old 09-12-2012
It does...
# 4  
Old 09-12-2012
Please post what Operating System and version you are running:
Code:
uname -a # Blotting anything confidential with Xs

And what version of Oracle you have.

The Korn Shell script as posted should work if it is invoked directly with full path as an executable script.
Please post the relevant line from crontab and a full directory listing of the script.

The "wait" not work if the "sqlplus" lines are actually other scripts which start a new Shell.
# 5  
Old 09-12-2012
I finally solved it. The problem was not thw "wait".

The sqlplus sessions weren't executing and there was nothing to wait for. I added the oracle path to the sqlplus calls, but still didnt work.

I had to do this at the begining of the file:

Code:
. /ora01/DWHR/files/relacional/.profile

Thanks for your help

Last edited by methyl; 09-12-2012 at 01:19 PM.. Reason: Please use code tags. Space characters are important in a command like this.
# 6  
Old 09-12-2012
Thank you for letting us know.

. /ora01/DWHR/files/relacional/.profile

Actually I can't imagine how this works unlesss it is preceded by a cd command or the environment script is in the home directory of the owner of the crontab.
Wherever possible use absolute path names in scripts run from cron.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In Shell Script Does Second Command Wait For First Command To Complete

Hi All, I have a question related to Shell scripting. In my shell script, I have following two commands in sequence: sed 's/^/grep "^120" /g' $ORIGCHARGEDAMTLIST|sed "s;$;| cut -f$FIELD_NO1 -d '|' | awk '{ sum+=\$1} END {printf (\"%0.2f\\\n\", sum/100)}' >$TEMPFILE mv $TEMPFILE $ORIGFILE... (3 Replies)
Discussion started by: angshuman
3 Replies

2. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

3. Shell Programming and Scripting

korn shell to cut command output

hello, i use following command: md5sum TEST.xml the output looks like: 900hjidur84hjr938ikv TEST.xml as you can see, the first part is the md5 code, the second part is the file name, but i only want the first part(md5 code), and save it to a file, how to do that? thanks. (2 Replies)
Discussion started by: zbc
2 Replies

4. Shell Programming and Scripting

MKS KORN SHELL WONT EXECUTE from windows command prompt

Can anybody help me with this small script , the script works fine and launches the IE from c:\documents and settings \test\my documents>ksh prompt $RunURL1.sh this scitpt works and launches the ie from ksh , but when i schedule it to run the script then i get the error box saying command:1... (2 Replies)
Discussion started by: venu
2 Replies

5. Shell Programming and Scripting

Shell script runs fine in Solaris, in Linux hangs at wait command

HI, I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging. here is the core of the script CFG_FILE=tab25.cfg sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" | while IFS="!" read a b c do #echo "jobs output" #jobs #echo "jobs... (13 Replies)
Discussion started by: aksaravanan
13 Replies

6. Shell Programming and Scripting

Find command in Korn Shell

Hi, I am trying to execute the below in Ksh (telnet) find ./request.txt -mmin -30 It says find: bad option -mmin What i am trying to do is by using find command i am checking wheather the file request.txt is there for 30 minutes or not Please help (1 Reply)
Discussion started by: chinniforu2003
1 Replies

7. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

8. Shell Programming and Scripting

problem with set command in korn shell

I have to copy an array to a temp variable and back after doing some functions. I am trying to see if it is possible to do without while loops.My closest try was set -A temp ${THE_ARRAY} # restore array after some actions set -A THE_ARRAY ${temp} The problem with above is that, the new... (1 Reply)
Discussion started by: vijay1985
1 Replies

9. UNIX for Dummies Questions & Answers

Maximum Command Length for Korn shell

What is the maximum size of a command which can be given in telnet command prompt in unixfor Korn shell? (2 Replies)
Discussion started by: miltony
2 Replies

10. Shell Programming and Scripting

Command ignored after sftp - korn shell

Hi all Trying to run my korn shell script, I got no messages after the sftp. The "finished" msg is not being displayed. Any ideas? sftp $argument <<EOF quit EOF echo "finished" Thanks in advance, :O) (1 Reply)
Discussion started by: alienET
1 Replies
Login or Register to Ask a Question