title: How to find/kill a specific python program
body: <p>There are two different python programs running in this VM</p>
  
  <p>one is a background job who monitors a folder and then 'does stuff' (with several workers)</p>
  
  <pre><code>10835 ?        Sl     0:03 python main.py
  10844 ?        Sl    34:02 python main.py
  10845 ?        S     33:43 python main.py
  </code></pre>
  
  <p>the second one is started via script</p>
  
  <pre><code>20056 pts/1    S+     0:00 /bin/bash ./exp.sh
  20069 pts/1    S+     0:00 /bin/bash ./exp.sh
  20087 pts/1    S+     0:10 python /home/path/second.py
  </code></pre>
  
  <p>i have tried numerous things to find a way to kill only the main program (i want to build a cron watchdog), but non succeded</p>
  
  <p>first one i want to find only the hanging 'python main.py' process (accompanied by [defunct]), but i cant even find just this process alone.</p>
  
  <p>the upper ones are from ps -ax (so they both are running currently)
  pgrep 'python' returns all PIDs, also from second.py which i dont want: (not usefull, so is pkill therefore)</p>
  
  <pre><code>pgrep 'python'
  10835
  10844
  10845
  20087
  </code></pre>
  
  <p>pgrep 'python main.py' always returns empty, so does pgrep 'main.py;</p>
  
  <p>the only thing which works </p>
  
  <pre><code>ps ax | grep 'python main.py'
  </code></pre>
  
  <p>but this one also returns its own PID, grepping 'ps' isn't a prefered solution afair. when main.py hangs, it shows "python main.py [defunct]". a </p>
  
  <pre><code>ps ax | grep 'python main.py [defunct]'
  </code></pre>
  
  <p>is useless as test as it always returns true. pgrep for anything more than 'python' also returns always false. i am a bit clueless.</p>