0

I want to launch a task through ssh and then exit my terminal and have my task continuing on my ssh server.

I have tried a bunch of things which did not work, such as :

laptop$ ssh server@ipaddress
server$ mytask &
[1] 12345
server$ logout

Or

laptop$ ssh server@ipaddress
server$ mytask
(then hit [Ctrl]+[Z])
server$ logout

Or even

laptop$ ssh server@ipaddress -f "mytask"
(and then close my terminal)

But even in my last attempt, closing my terminal would stop the task.

How should I proceed?

Thanks in advance!!

marked as duplicate by Kusalananda bash Feb 17 '18 at 11:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    I think you need nohup tool ssh userid@host "nohup command & " then you an close your local terminal but task will follow its own execution on remote host – francois P Feb 17 '18 at 11:40
  • 1
    ... or leave the connection open (with ssh -n), but nohup is better. – Ned64 Feb 17 '18 at 11:41
  • @francoisP Why don't you make an answer out of your suggestion? It can be one. – Ned64 Feb 17 '18 at 11:42
  • see also unix.stackexchange.com/questions/479/… – cas Feb 17 '18 at 11:42
  • Thank you very much @francoisP !! That's exactly what I needed :) – Johannes Lemonde Feb 17 '18 at 11:53