I have an potentially infinite python 'while' loop that I would like to keep running even after the main script/process execution has been completed. Furthermore, I would like to be able to later kill this loop from a unix CLI if needed (ie. kill -SIGTERM PID), so will need the pid of the loop as well. How would I accomplish this? Thanks!
args = 'ping -c 1 22.214.171.124' while True: time.sleep(60) return_code = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE) if return_code == 0: break