I am trying to kill java process with name "MyClass" using below python script :
import os
os.system("kill $(ps aux | grep 'MyClass' | grep -v 'grep' | awk '{print $2}')")
But this gives me output as below and the process is still running
sh: 1: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or
kill -l [exitstatus]
512
I know that the $ sign is the problem here but do not know how to make this work.
Any help/hint is appreciated. Thanks.
ps aux | grep 'MyClass' | grep -v 'grep' | awk '{print $2}')?