How to run Node.js as a background process and never die?

前端 未结 14 1100
刺人心
刺人心 2020-11-22 10:59

I connect to the linux server via putty SSH. I tried to run it as a background process like this:

$ node server.js &

However, after 2.5

14条回答
  •  旧时难觅i
    2020-11-22 11:40

    You really should try to use screen. It is a bit more complicated than just doing nohup long_running &, but understanding screen once you never come back again.

    Start your screen session at first:

    user@host:~$ screen
    

    Run anything you want:

    wget http://mirror.yandex.ru/centos/4.6/isos/i386/CentOS-4.6-i386-binDVD.iso
    

    Press ctrl+A and then d. Done. Your session keeps going on in background.

    You can list all sessions by screen -ls, and attach to some by screen -r 20673.pts-0.srv command, where 0673.pts-0.srv is an entry list.

提交回复
热议问题