views:

426

answers:

2

I want run a script as follows:

runner: ssh 'java program &' ssh 'java program &'

How do I write the script to fork the first process? Currently, it waits for it to finish.

thanks

A: 

Actually, I think you want

ssh -f -n remotesystem 'command&'
DigitalRoss
A: 

In your script:

#!/bin/sh
ssh yourhost 'java program &' &
ssh yourhost 'java program &'

The first ssh will start a session running a java program in the background. If the java program is a graphical application and you are running with port forwarding enabled the ssh process will still continue running even after the command java program & is finished. By adding the final & to the first command line the ssh program will be put running in the background.

hlovdal