Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

653
Visualizações
Execute command with SSH.NET without blocking and keep it running after closing the connection

I'm using the following code:

using (var client = new SshClient(host, user, pass))
{
    client.Connect();

    var terminal = client.RunCommand("/home/my-script.sh");
}

The client.RunCommand hangs because the command I'm using is creating a thread. I'd like the command to be executed and not wait for the thread to be finished. How would I dot it?

So to sum up, I want to:

  • Send the command that creates a background work (thread)
  • while the background work is being accomplished, I should be able to close the session/connection with the intention of the background work continuing

Reference: https://csharp.hotexamples.com/examples/Renci.SshNet/SshClient/RunCommand/php-sshclient-runcommand-method-examples.html

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is not really SSH.NET question, but rather a generic SSH/shell question.

See How to make a program continue to run after log out from ssh?

So this should do:

client.RunCommand("nohup /home/my-script.sh > foo.out 2> foo.err < /dev/null &");
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda