Hi all , i have writting my little node js file that run mysql querys for me what i need to know is how i keep this running when i am not connected as it will need to do this when i am not at the computer
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Greetings!
There are several ways to go about this. The dirtiest way (in my opinion) is simple but not fault tolerant, and it uses a screen session. So, for example, if this were Debian/Ubuntu:
Then
CTRL+A
followed byCTRL+D
to detach from the screen session. This persists when you log out of your SSH session.However, I recommend something a bit more powerful if you’re up for it. You can use PM2 as a manager for this, and we have a tutorial here:
https://www.digitalocean.com/community/tutorials/how-to-use-pm2-to-setup-a-node-js-production-environment-on-an-ubuntu-vps
Obviously you don’t need all of that tutorial, but you should be able to extract what is relevant to you.
Jarland