Today I continued to work on our internal company server which will provide the IAM service. As the service app prompts for the service password when starting it’s not possible to use my favorite process manager for Node.js called „pm2“. Instead a colleague mentioned „screen“, a terminal multiplexer. I knew this little helper before but never used it. Now it comes in handy as you are able to run the script in a screen, pass the password and then detach the screen from your current ssh session.
In your ssh session type
which will bring up the first „window“ (a new terminal session). In the new session just run the script with
and provide the password.
Then hit CTRL+A and then D which will detach the screen from the real ssh session (the window will close). Now you can disconnect your ssh session but the script will continue to run.
If you have to stop the script at some point, recall the screen with
You will see the script is still running. Now you can terminate it with CTRL-C.