views:

29

answers:

2

Hi All,

I'm trying to run a script, which internally invokes other script

but, the main script should exit after invoking and the invoked script should run independently on the background.

How can i achieve this in shell scripting? or is there any other alternative way to do this?

Regrads, senny

+3  A: 
nohup otherscript &

The nohup will ensure that the process keeps running even if the current terminal goes away (for example if you close the window).

(Just to make it clear: the "&" puts the other script in the background, which means the first will keep running, and the second script won't exit when the first one does.)

psmears
i'm not taking about closing terminal, it is a shell script which will invoke one more script. The invoked script should keep running, where as the main script should exit immediately after invoking the new script...
@user57421: Yes, and the above will do exactly that!
psmears
Thanks a lot.. I tested it...
A: 

If your script is in Perl, use exec() command to start the second script. exec() returns immediately after executing the command, and the calling script can exit, while the second script keeps running.

http://perl.about.com/od/programmingperl/qt/perlexecsystem.htm

jprusakova
Thank you. But can this be done using shell scripting.. i'm using ksh..
@jprusakova: exec() doesn't quite do what you think: it does run the command, but it also terminates the perl script (try it!)
psmears