When I run a command in a Linux script that starts a process, I'd like to capture the process number for that command in a variable for later use (i.e. to kill it later on).
Here's the command that starts the process
./run external
Would it be something like:
./run external/ pid=$!?
Manually I do: ps -ef|grep run
, which gives me a process ID and then I can kill it manually but I want to capture the PID in the script in a variable so I can say: kill $variable
(that has the PID value in it).
Ideas?