1

In my script I SSHed a host and tried to run two java programs. The first java program runs with nohup and & at the end. After that I try to run another java program but it gives syntax error. I guess it has something to do with the &. I do not want to ssh again.

ssh $host "nohup java -cp daemon.jar:. runtime.daemon.MPJDaemon >>/logs/$host-wrapper.log 2>&1 &;java Health"

It gives bash: -c: line 0: syntax error near unexpected token `;

Any ideas

shujaat
  • 279
  • 6
  • 17
  • possible duplicate of [how to run a command in background using ssh and detach the session](http://stackoverflow.com/questions/1628204/how-to-run-a-command-in-background-using-ssh-and-detach-the-session) –  Apr 18 '12 at 04:56

1 Answers1

1

In bash, & implies semicolon (;), so you don't really need that semicolon after the ampersand

From http://hacktux.com/man/bash

If a command is terminated by the control operator &, the shell executes the command in the background in a subshell.

Andreas Wong
  • 59,630
  • 19
  • 106
  • 123