I am using bash to start several instances of one python program, like this:
python example.py -id $i
where $i
is the id given to the instance. All the processes are started on the same user, and imagine I am unable of keeping track of the process IDs. Would it be possible to kill the specific instance just by the command (with id) that called it? For example something like pkill 'python example.py -id 2
which obviously doesn't work.
pkill -f python example.py -id 2
. The man page for pkill explains the-f
flag (seeman pkill
). And generally, it's a good idea to quote your variables ("$i"
instead of just$i
). – roaima Jul 25 '16 at 21:42jobs
command and thenkill %2
or whatnot may be of use, to use the shell job control functionality. – thrig Jul 25 '16 at 22:21