简体   繁体   English

ssh之后在bash脚本中运行两个Java程序

[英]Run two java programs in a bash script after ssh

In my script I SSHed a host and tried to run two java programs. 在我的脚本中,我通过SSH主机,并尝试运行两个Java程序。 The first java program runs with nohup and & at the end. 第一个Java程序以nohup和&结尾运行。 After that I try to run another java program but it gives syntax error. 之后,我尝试运行另一个Java程序,但它给出了语法错误。 I guess it has something to do with the &. 我想这与&有关。 I do not want to ssh again. 我不想再次ssh。

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 `; 它给出bash:-c:第0行:意外令牌`附近的语法错误;

Any ideas 有任何想法吗

In bash, & implies semicolon ( ; ), so you don't really need that semicolon after the ampersand 在bash中, &表示分号( ; ),因此您在与号后实际上不需要分号

From http://hacktux.com/man/bash 来自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. 如果命令由控制操作符&终止,则外壳程序将在子外壳程序的后台执行该命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM