0

基本上我在一个 ant 目标中有 2 个 sshexec 任务,一个接一个。第一个在一台机器上启动消息发送者,第二个在另一台机器上启动消息接收者。我假设 sshexec 任务将发出命令来运行消息发送方,然后在发送方运行时返回,然后下面的 sshexec 任务将启动接收方,因此发送方和接收方将并行运行,这是我希望实现的,但我不确定是否真的是这样,或者实际上第一个任务只会在发送方返回时返回,因此接收方只有在发送方完成执行后才会开始。

sshexec 任务页面似乎没有提供太多信息,而且我对 mac 有点陌生(这些命令是在运行 macos 10 的 mac minis 上发出的),所以任何帮助将不胜感激,谢谢!

    <!--start sender-->
    <sshexec host="${ip.client3}"
                 username="${username}"
                 password="${userpassword}"
                 trust="true"
                 command="./sender"
    />

    <!-- start receiver-->
    <sshexec host="${ip.client4}"
                 username="${username}"
                 password="${userpassword}"
                 trust="true"
                 command="./receiver "
    />
4

1 回答 1

2

<sshexec> task will return after the remote command returns.

If you just want the two commands to start at the same time, you can use <parallel> task. Any task nested in <parallel> task will run "at the same time" by multi threading. However, in this way, <sshexec> still need to wait for the two commands to return.

If you just want your ant script to launch those two commands and continue building without waiting for remote commands to return, you may use things like nohup in your commandline.

I am not sure if nohup works, because when I run a remote command from a ssh terminal with nohup like this:

nohup command & [ENTER]

I have to press enter again before I start to use the same terminal to do something else.

于 2012-04-25T05:27:34.313 回答