I'm trying to get the PID of a shell script so I can kill it at a later date.
bash "home/lewis/builds/arduino/arduino-1.8.12/arduino" & disown echo "$!"
The above runs and returns 37977
when I run
kill 37977 I get
bash: kill: (37977) - No such process
I assume this is because the script
/home/lewis/builds/arduino/arduino-1.8.12/arduino then spawns other processes which are not 37977.
Is there a way I can get hold of the final PID of a shell script or any other command I run, usually it works a charm but this instance is causing me an issue.
I need a solution that's transferable to other commands in case this happens again.