I have file named test.py and I am trying to run below command as a background process as part of this script
"tail -n0 -f debug.log"
Also, I want this process to end as soon as test.py execution is completed. However, I can't get this to working. I have tried below code but tail command not exiting even after main script is completed. I am new Python, can someone help me do this clean way ?
pro = subprocess.Popen(["tail", "-n0", "-f", log_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in pro.stdout:
print(line)
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)