I'm running into a weird behavior for a certain app I'm using. If I start the command in the background in bash, I can kill it using
$ command &
$ kill -n 2 [PID of command]
killing command gracefully
However, when I throw this into a script:
command &
ID=$!
kill -n 2 $ID
it doesn't do anything at all. Is there some subtly I'm missing?
Edit: Another clue is that once the script stops running, I can't kill the command using kill -n 2.
ID=command&doesn't do what you think.