Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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()
Comment

PREVIOUS NEXT
Code Example
Python :: python circular import 
Python :: pandas count empty string values 
Python :: python openpyxl csv to excel 
Python :: python regular expression 
Python :: how to copy file from local to sftp using python 
Python :: pivot pyspark 
Python :: write pyspark dataframe to csv 
Python :: python cut string to length 
Python :: destroy label tkinter 
Python :: merge two dictionaries 
Python :: how to make a dict from a file py 
Python :: pyautogui locatecenteronscreen mac fix 
Python :: how to use the super 
Python :: arg parse array argument 
Python :: seaborn barplot remove error bars 
Python :: how to run a python script in background windows 
Python :: how to see the whole dataset in jupyterlab 
Python :: python ffmpeg get video fps 
Python :: captions overlap in seaborn plot jupyter 
Python :: numpy generate random array 
Python :: python crear dataframe 
Python :: how to cut image python 
Python :: hungry chef solution 
Python :: python get cos sim 
Python :: python run code at the same time 
Python :: python range in intervals of 10 
Python :: python pretty print list of tuples 
Python :: merge pandas datasets 
Python :: no python application found, check your startup logs for errors 
Python :: python sys.argv exception 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =