node xxx.js
这行命令当按下control + c,进程就会退出。如果需要进程在后台保持运行,需要
node xxx.js &
nohup node xxx.js &
默认stdout和stderr都会重定向到nohup.out
[root@yilos-dev-image trace_test]# nohup node test.js &
[1] 31767
[root@yilos-dev-image trace_test]# nohup: 忽略输入并把输出追加到"nohup.out"
可以重定向到不同的位置:
[root@yilos-dev-image trace_test]# nohup node test.js >> app.log &
[1] 31803
[root@yilos-dev-image trace_test]# nohup: 忽略输入重定向错误到标准输出端
用上面的命令,stdout和stderr都重定向到app.log文件
如果希望分离stdout和stderr,可以用下面的命令
[root@yilos-dev-image trace_test]# nohup node test.js 1>>app.log 2>>error.log &
[1] 31851
console.log()
console.trace()