rubencaro / sshex

Simple SSH helpers for Elixir. SSH is useful, but we all love SSHEx !

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to open a background process

vans163 opened this issue · comments

Passing the send to background operator keeps the connection blocked until its done executing. Example SSHEx.run(conn, "sleep 10 &"), there should be a way to send processes to execute in background.

Not a SSHEx problem, not even Erlang's :ssh, but a general SSH behaviour. You must redirect the output to a file to make SSH let you close the connection. Try this: SSHEx.cmd!(conn, "sleep 10 > /dev/null 2>&1 &").

It's the same you need to do when running remote commands through SSH directly from shell (i.e. ssh user@server "sleep 10 > /dev/null 2>&1 &").

Note that if you place the & outside of the remote command, you are actually keeping the connection open in the background (i.e. ssh user@server "sleep 10" &). That would be similar to run SSHEx.cmd! in a separate process, like spawn fn -> SSHEx.cmd!(conn, "sleep 10") end.