in reply to Slightly OT - automating nohup bg jobs...

I'm not sure why you are using backticks and trying to print the result since you are trying to background the job, but I'm not sure that matters.

I'm no ssh guru, but I'm assuming ssh is keeping the session open since stdout and stderr are still open. If I redirect stdout and stderr, it seems to work ok for me on Linux. You may also want to redirect stdin as well. Try something like this...

print `ssh myhost "nohup nice perl script.pl </dev/null >/dev/null 2>& +1 &"`;
Another option might be to backround the ssh process on your local machine instead (though these will of course accumulate).

bluto

Replies are listed 'Best First'.
Re:^2 Slightly OT - automating nohup bg jobs...
by cLive ;-) (Prior) on Jan 23, 2004 at 06:28 UTC
    Thanks for input. FYI, the output gets appended to the nohup.out file by default and is useful to tail when testing (at least on FreeBSD). I'm not an expert on this at all - just hacks I found that seem to be useful.

    I really should learn bash in detail at some point...

    cLive ;-)

      I'm not sure that nohup is sufficient though to completely close stdout and stderr. I think the shell you spawn on the remote machine is itself holding a copy of these open.

      FWIW, I use zsh for my main shell, but almost always write scripts that are sh/ksh compatible since these are installed on almost every unix-like machine (and much more consistent than using csh).

      bluto