如何让nodejs在linux后台运行

2025-02-24 13:14:56
推荐回答(2个)
回答1:

chmod a+x yournodejs
./yournodejs

回答2:

pm2 或者 forever

抑或自带的nohub服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
pm2:
sudo npm install -g pm2

pm2 start index.js --name hello
pm2 stop hello
pm2 restart hello

forever:
sudo npm install -g forever
forever start index.js
...

nohub:
nohup node index.js > ~/myout.log 2>&1 &