spawn forks a new local ssh process that continues running on the background until the remote process exits and you have to take care of reaping those ssh processes with waitpid, otherwise zombies will pile up and at some point the OS will refuse to fork new processes... and that is probably the reason for your script failing.
The right way to do that is to run the remote command with nohup:
Though, as it seems that the remote command is actually a Perl script, you can also convert it into a daemon letting it take the responsibility of going into the background. There are several CPAN modules that allow to do that (i.e. Proc::Daemon).$ssh->system("nohup ./script.pl &");
Besides that, there are other places where you can improve your Net::OpenSSH usage:
...can just be written as...
And in...$ssh->system({stdout_file => ['>>', $local_file]}, cat => $remote_file).
you should check that the command did not fail due to some SSH error. Otherwise, you could end running several instances of ./script.pl.my $PROC = $SSH->capture( "ps aux | grep <process_name> | grep -v grep + | wc -l | sed 's/ *//'" ); if( $PROC == 0 ) {...
In reply to Re^3: Net::OpenSSH killing script
by salva
in thread Net::OpenSSH killing script
by jaiieq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |