I have a Node progress. I want to auto-start it and keep it in background via a shell script. The way I keep background progress is press crtl+Z after run npm run start
, then run bg && disown
. Now I’ve got a problem: How to process this crtl+Z command in Shell script?
Advertisement
Answer
Another way to run a script in the background is to simple write:
npm run start &
The ampersand starts the process up in the background and makes it so you don’t have to worry about processing ctrl-z. If you were dead set on using ctrl-z however, this is actually just a SIGTSTP interrupt and
kill -SIGTSTP [PID]
could be used to emulate it.