I have a very simple problem: When I run a shell script I start a program which runs in an infinite loop. After a while I wanna stop then this program before I can it again with
In bash $! expands to the PID of the last process started in the background. So you can do:
$!
./app1 param1 & APP1PID=$! # ... kill $APP1PID