Question

I have:

$ cat ./test
#!/bin/bash

gulp dev &

Then run it:

$ ./test
...

(.. hit enter to get command prompt) The command in the script starts node process. But I haven't it among background processes:

$ jobs -p

prints empty list. So the aim is to be able to list/kill (multiple) processes started and detached inside a single script. How to?

Was it helpful?

Solution

Your interactive shell only manages the jobs that it started. When you run a script as a command, the background processes are started by the subshell, not the original shell.

You need to source the script, so that it will be run by your interactive shell:

source ./test
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top