How to run as background process
If you turn off the Auto-off feature, the container will remain running even if you close the workspace, but processes running in the terminal will be terminated. To prevent this, you need to run the process as a background process.
There are 2 options to set-up;
Run in the background setting (recommended!)
Use
nohup
command
Run in the background setting
Enter the execution command in the script, then tap the Run in the background checkbox to run the command.
command tap → Run → click right on wanted run command → setting → check Run in the background → Save and run.
Use nohup command
How to run
If the file to be run in the background process is a.out
, you can run it as a background process by entering the following command in the terminal.
# nohup <absolute path>/ filename &
You can check for execution with the command below.
# ps -aux | grep a.out
How to end
After finding the PID value with the ps command, end the process with the kill command.
# ps -ef | grep a.out
# kill -TERM PID number
This file records the output of the commands you run with nohup
.
If you don't want to create this file, you can have it output to /dev/null.
# nohup echo hello > /dev/null
If you are using node app
You can simply run it as a background process using the forever command in the npm package.
Install forever
$ npm install -g forever
Run the app with the command below
$ forever start app.js
You can verify whether it's running or not with the command below.
$ forever list
An app that uses npm start
You can run the command set in scripts.start
of package.json
using npm start
, but with PM2, you can run it more easily as a background application.
Install pm2
$ npm install -g pm2
Run the app with the command below
$ pm2 start npm -- start
You can verify whether it's running or not with the command below.
$ pm2 status
Last updated
Was this helpful?