I want to kill a python script that runs on my system from another python script.
I followed this answer and tweaked the code a bit, but got an error:
Traceback (most recent call last): File "/home/pi/base.py", line 13, in <module>
check_call(["pkill", "-9", "-f", script])
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['pkill', '-9', '-f', '/home/pi/MotionDetector.py']' returned non-zero exit status 1
Code:
from subprocess import check_call
import sys
import time
script = '/home/pi/MotionDetector.py'
check_call(["pkill", "-9", "-f", script])