Sep-19-2019, 08:48 AM
I have a jar and I want to make a python script for linux that checks if the jar is opened in the linux task manager and if its not to open it 5 times. From time to time it should check the 5 processes and when all 5 end open them again.
This is the code that I`ve written in python:
How can I modify the script so it opens up 5 processes ?
Thanks
This is the code that I`ve written in python:
import psutil import subprocess process_name = "/root/Linux/ArhivareProd.jar" for proc in psutil.process_iter(): process = psutil.Process(proc.pid) pname = process.name() if pname != process_name: subprocess.call(['java','-jar','/root/Linux/ArhivareProd.jar']) subprocess.call(['java','-jar','/root/Linux/ArhivareProd.jar']) subprocess.call(['java','-jar','/root/Linux/ArhivareProd.jar']) subprocess.call(['java','-jar','/root/Linux/ArhivareProd.jar']) subprocess.call(['java','-jar','/root/Linux/ArhivareProd.jar']) else: print("Minim un proces ArhivareProd.jar deja ruleaza !")When I run it it only opens one jar process
How can I modify the script so it opens up 5 processes ?
Thanks