Background execution of a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Background execution of a script
# 1  
Old 10-03-2007
Background execution of a script

Hi All,

Have a script called FTPIN-xx.sh.
It does stuff and when all is done, it is to execute another.
However, I'd like to have it execute the second script in the background or in a fashion that would allow my script to complete without having to wait.

I'm robbing the command from how I set items in crontab just to maintain some consistancy, but anyways ...

I thought I might be able to do the following:

nice ksh -c "${MD_BATCH}/The2ndScript.sh ${UID} ${PWD} &" >> ${MD_BATCHLOG}/The2ndScript.log 2>&1
-- OR --
nice ksh -c "${MD_BATCH}/The2ndScript.sh ${UID} ${PWD}" >> ${MD_BATCHLOG}/The2ndScript.log 2>&1 &


But am not too sure what happens to STDOUT for The2ndScript when FTPIN-xx.sh completes.

Any suggestions/thoughts ??

Thanks in advance. Smilie

Cheers,
Cameron
# 2  
Old 10-03-2007
Try putting /bin/ksh at the start on The2ndScript.sh then you don't have to keep refering to it.

The stdout of the background process will go to the file, when the task finishes the file will be closed.

That's all that happens.

I personally would go for your 2nd form, I try and always put "&" at the very end of the line to avoid confusion.
# 3  
Old 10-03-2007
Bug

Thanks for the reply porter.

#!/bin/ksh - is standard for all of my scripts, so that's a given (in my case anyways).

The second option is my preference too, though the first was after wondering about the STDOUT issue.

Thanks for your help porter - appreciate your opinion and the feedback.

Cheers,
Cameron
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running script in background

Hi, I wrote a KSH script and running it on HP-UX machine I am running one script in background. My script is at location $HOME/myScript/test/background_sh When I view my script in background with psu commend > psu | grep background_sh I see following output UID PID PPID C ... (1 Reply)
Discussion started by: vaibhav
1 Replies

2. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

3. Solaris

Script on Solaris spawning 2 processes for one shell script execution

Hi, I am having a shell script on Solaris 10 which has a while loop as shown below. #!/usr/bin/ksh # while do sleep 60 done Name of the shell script is coldcentric.sh. I executed script /DATAWAREHOUSE/LOAD/Scripts/coldcentric.sh from a command task in Informatica worklow as... (3 Replies)
Discussion started by: chekusi
3 Replies

4. Shell Programming and Scripting

snoop script in background

Hi I want to write a script for snoop which can do snoop for 30 min and then process should be killed automatically I am using below codes #!/usr/bin/ksh snoop -d igb0 -o /opt/temp/abc.pcap sleep 1500 kill -9 `ps -ef|grep -i snoop |grep -v grep|awk '{print $2}'` But process is not... (3 Replies)
Discussion started by: anish19
3 Replies

5. Shell Programming and Scripting

running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the... (3 Replies)
Discussion started by: maitree
3 Replies

6. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

7. Shell Programming and Scripting

Running a unix script(which is calling another script inside that) in background

Hi all, I am having a script ScriptA which is calling a script ScriptB in the same server and copying files to second server and have to execute one script ScriptC in the second server. THis First script ScriptA is the main script and i have to execute this process continously. for Keeping... (2 Replies)
Discussion started by: rohithji
2 Replies

8. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

9. UNIX for Advanced & Expert Users

Running script in background

When I run the following snippet in background #!/bin/ksh while do echo "$i" sleep 10 i=`expr $i + 1` done My job got stopped and it says like + Stopped (SIGTTOU) ex1 & I did "stty tostop" as suggested in many of the post but still not working... (3 Replies)
Discussion started by: shahnazurs
3 Replies

10. Programming

execution in background

hey im having trouble understanding how to execute commands in the background. i did some research and saw that you only have to fork and not wait for the child to finish. in another case you have to change the process group. i ve really tried both of them but i just cant get them to work. ... (0 Replies)
Discussion started by: mile1982
0 Replies
Login or Register to Ask a Question