Answers for "have python script continuously run in background"

1

how to check any script is running in background linux using python

def check_process():
    import subprocess
    script_name = "test.py"
    cmd='pgrep -f .*python.*{}'.format(script_name)
    process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    my_pid, err = process.communicate()
    if len(my_pid.splitlines()) >0:
        print("Script Running in background")
        sys.exit(0);
check_process()
Posted by: Guest on June-29-2020
0

have python script continuously run in background

another method is with "pythonw" library. 

pip install pythonw

See here the details:

https://neculaifantanaru.com/en/python-notifies-me-when-a-certain-product-appears-in-the-store-depending-on-the-lowest-price.html
Posted by: Guest on March-16-2022

Code answers related to "have python script continuously run in background"

Python Answers by Framework

Browse Popular Code Answers by Language