Background execution of a script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Background execution of a script

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-03-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
 
Join Date: Nov 2001
Last Activity: 23 October 2011, 10:07 PM EDT
Location: Brisbane, Australia
Posts: 509
Thanks: 7
Thanked 0 Times in 0 Posts
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.

Cheers,
Cameron
Sponsored Links
    #2  
Old 10-03-2007
porter porter is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 8 January 2008, 6:50 PM EST
Posts: 2,965
Thanks: 0
Thanked 5 Times in 5 Posts
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.
Sponsored Links
    #3  
Old 10-03-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
 
Join Date: Nov 2001
Last Activity: 23 October 2011, 10:07 PM EDT
Location: Brisbane, Australia
Posts: 509
Thanks: 7
Thanked 0 Times in 0 Posts
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
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem running a program/script in the background from a script newbie_01 Shell Programming and Scripting 5 03-28-2011 03:14 AM
Running a unix script(which is calling another script inside that) in background rohithji Shell Programming and Scripting 2 11-06-2009 01:52 AM
Expect Issue Serial Forground Execution vs Concurrent Background Execution twk Shell Programming and Scripting 2 09-14-2009 09:27 PM
how to run script at background happyv Shell Programming and Scripting 4 09-22-2006 08:39 AM
execution in background mile1982 Programming 0 10-12-2004 09:14 AM



All times are GMT -4. The time now is 09:11 PM.