I am working on the Ubuntu system on Amazon Web Services EC2. I have created an instance and need to run a node.js server on the system. Once I ssh into my working directory and use the following command,
:~/Test1$ node server.js
the server works fine. The code runs without any issues
Now, what I want is to run the server.js code even when the terminal is closed, as a background process. For that, I am using
nohup command with
:~/Test1$ nohup node server.js &
This, also gets the server.js started but the
nohup command seems nonfunctional since the server.js stops working when I close the terminal. I tried the code with
sudo command as well
:~/Test1$ nohup sudo node server.js &
but it does nothing.
What am I doing wrong? And, how shall I get this working? Thanks.