Python Forum
How to run same process simultaneously
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run same process simultaneously
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:

import psutil

import subprocess

process_name = "/root/Linux/ArhivareProd.jar"

for proc in psutil.process_iter():

process = psutil.Process(

pname =

if pname != process_name:['java','-jar','/root/Linux/ArhivareProd.jar'])['java','-jar','/root/Linux/ArhivareProd.jar'])['java','-jar','/root/Linux/ArhivareProd.jar'])['java','-jar','/root/Linux/ArhivareProd.jar'])['java','-jar','/root/Linux/ArhivareProd.jar'])


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 ?

procs = []
for i in range(5):
    p = subprocess.Popen(['java','-jar','/root/Linux/ArhivareProd.jar'])
from p in procs:

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to sharing object between multiple process from main process using Pipe Subrata 1 1,262 Sep-03-2019, 09:49 PM
Last Post: woooee
  Control 2 stepper motor simultaneously jihene 2 1,272 May-08-2019, 05:27 PM
Last Post: DeaD_EyE
  Moving with objects simultaneously kom2 1 776 Apr-20-2019, 07:12 PM
Last Post: SheeppOSU
  using subpocess for both reading and writing simultaneously dauriac 11 3,929 May-30-2018, 10:09 PM
Last Post: killerrex
  controlling multiple server simultaneously. caligola 3 1,361 May-11-2018, 05:44 PM
Last Post: wavic
  How to define two functions run simultaneously within a function? Alberto 4 1,753 Feb-06-2018, 10:08 PM
Last Post: Alberto
  Modifying / extracting multiple list items simultaneously using variable from range ehammarlund 4 1,737 Dec-06-2017, 08:15 PM
Last Post: ehammarlund

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020