I tried to use subprocess as a way to continuously run a python script even after closing the browser, using the start and stop pages on https://flazepe.gitbook.io/heliohost/tutorials/discord-bot But no matter how long I waited, the script only ran when the "start" page was open, and when I tried to stop the script, it told me that there was no script to stop. my start script is #!/usr/bin/python3.7 print("Content-Type: text/html\n\n") import os, subprocess, signal counter = 0 p = subprocess.Popen(['ps', '-u', 'andyye03'], stdout=subprocess.PIPE) # must match your username --------^^^^^^^^ out, err = p.communicate() for line in out.splitlines(): if 'gaonnuriallimi.py'.encode('utf-8') in line: # ^^^^^^^^^^^----- this has to match the filename of your bot script counter += 1 print("Bot already running.") if counter == 0: subprocess.Popen("/home/andyye03/gaonnuriallimi.py") # ^^^^^^^^-- be sure to update it to your username print("Bot started!") and my stop script is #!/usr/bin/python3.7 import os, subprocess, signal print("Content-Type: text/html\n\n") counter = 0 p = subprocess.Popen(['ps', '-u', 'andyye03'], stdout=subprocess.PIPE) # must match your username --------^^^^^^^^ out, err = p.communicate() for line in out.splitlines(): if 'gaonnuriallimi.py'.encode('utf-8') in line: # ^^^^^^^--- this has to match the filename of your loop counter += 1 pid = int(line.split(None, 1)[0]) print("Stopping bot.") os.kill(pid, signal.SIGTERM) if counter == 0: print("Already stopped.")