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

前端 未结 20 1347
悲&欢浪女
悲&欢浪女 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条回答
  •  -上瘾入骨i
    2020-11-22 06:57

    nohup is very good if you want to log your details to a file. But when it goes to background you are unable to give it a password if your scripts ask for. I think you must try screen. its a utility you can install on your linux distribution using yum for example on CentOS yum install screen then access your server via putty or another software, in your shell type screen. It will open screen[0] in putty. Do your work. You can create more screen[1], screen[2], etc in same putty session.

    Basic commands you need to know:

    To start screen

    screen


    To create next screen

    ctrl+a+c


    To move to next screen you created

    ctrl+a+n


    To detach

    ctrl+a+d


    During work close your putty. And next time when you login via putty type

    screen -r

    To reconnect to your screen, and you can see your process still running on screen. And to exit the screen type #exit.

    For more details see man screen.

提交回复
热议问题