user3116204
user3116204

Reputation: 1

ssh & perl & running in the background

Both host are *nix

On host two there are two perl scripts nfs1 and nfs2.

The script nfs1 runs script nfs2 multiple times in the background

system("/usr/local/scripts/nfs2 -m $mountpt &");

When run locally, it works just fine.

When run on a different host via ssh

ssh testhost /usr/local/bin/nfs1

ssh will wait until the script(s) nfs2 have completed

To test I added to nfs2 a sleep of 10 seconds.

running nfs1 takes 'zero' time, and you can see via ps nfs2 running then ending 10 seconds later.

When I ssh /usr/local/scripts/nfs1 it takes 10.8 seconds, changing the sleep to 5, get me 5.8 seconds. I'll figure out the .8 later.

Ideas ?

-pete

Upvotes: 0

Views: 310

Answers (1)

William Pursell
William Pursell

Reputation: 212248

Most likely the script nfs2 has file descriptors open on the ssh link. Close them. Either rewrite nfs2 so that it properly daemonizes itself and closes all of its file descriptors, or modify nfs1 to call it with the descriptors closed or redirected. That is:

system("/usr/local/scripts/nfs2 -m $mountpt < /dev/null > /dev/null 2>&1 &");

Upvotes: 2

Related Questions