How to prevent a background process from being stopped after closing SSH client in Linux

前端 未结 20 1321
悲&欢浪女
悲&欢浪女 2020-11-22 06:16

I\'m working on a Linux machine through SSH (Putty). I need to leave a process running during the night, so I thought I could do that by starting the process in background (

20条回答
  •  礼貌的吻别
    2020-11-22 07:02

    Append this string to your command: >&- 2>&- <&- &. >&- means close stdout. 2>&- means close stderr. <&- means close stdin. & means run in the background. This works to programmatically start a job via ssh, too:

    $ ssh myhost 'sleep 30 >&- 2>&- <&- &'
    # ssh returns right away, and your sleep job is running remotely
    $
    

提交回复
热议问题