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

前端 未结 14 940
刺人心
刺人心 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条回答
  •  遇见更好的自我
    2020-11-22 11:16

    I have this function in my shell rc file, based on @Yoichi's answer:

    nohup-template () {
        [[ "$1" = "" ]] && echo "Example usage:\nnohup-template urxvtd" && return 0
        nohup "$1" > /dev/null 2>&1 &
    }
    

    You can use it this way:

    nohup-template "command you would execute here"
    

提交回复
热议问题