I have a fairly simple script like so:
nohup java -jar program.jar >> log 2>&1 &
echo $! > pidfile
This works great when using ssh server "script.sh" but not when using ssh -t server "script.sh"
The solution I came up with was to call sleep after recording the child pid. My guess at the problem is that the script and pseudo-tty are destroyed before the child process actually starts. Is there a better way to wait until the child starts before returning? Should I use something other than nohup to ensure the child starts?
I have to use ssh -t because of other constraints.