I'm looking to write a python script that would allow me to start a jar file I have on my computer, wait 3 seconds and then kill it. Currently, I'm on step 2 and I can't find a way to kill my process. It's vital since if I forget to kill it, it's gonna occupy a port on my machine and I'm gonna have to manually find it and kill it by pid.
So, how do I do that ?
Thanks in advance, here's my small code:
from msilib.schema import Error
import psycopg2
import subprocess
import time
# Define the path where your jar is built
path = '...'
< some sql interactions >
conn.commit()
conn.close()
# Calling the java
subprocess.call(['java', '-jar', path])
time.sleep(3)
# kill the subprocess