Skip to main content
Tweeted twitter.com/StackUnix/status/716661457665069056
improved readability
Source Link
techraf
  • 6.1k
  • 11
  • 36
  • 51

Finding number of child processes of a particular process

I have a pythonPython script that spawns a few subprocesses but never more than n at a time. 

I want to write a shell script to confirm that it has no more than n subprocesses at any given time, but also that generally it has n processes running. 

If I have the pidPID of the pythonPython program inside a shell script, how do I check the number of subprocesses that that pidPID currently has? E.g.

python script.py &
pid=$!
while true
do
    # do something that prints number of subprocesses of
    # the process $pid to stdout
    sleep 1
done

Finding number of child processes of particular process

I have a python script that spawns a few subprocesses but never more than n at a time. I want to write a shell script to confirm that it has no more than n subprocesses at any given time, but also generally has n processes running. If I have the pid of the python program inside a shell script, how do I check the number of subprocesses that that pid currently has? E.g.

python script.py &
pid=$!
while true
do
    # do something that prints number of subprocesses of
    # the process $pid to stdout
    sleep 1
done

Finding number of child processes of a particular process

I have a Python script that spawns a few subprocesses but never more than n at a time. 

I want to write a shell script to confirm that it has no more than n subprocesses at any given time, but also that generally it has n processes running. 

If I have the PID of the Python program inside a shell script, how do I check the number of subprocesses that that PID currently has? E.g.

python script.py &
pid=$!
while true
do
    # do something that prints number of subprocesses of
    # the process $pid to stdout
    sleep 1
done
added 17 characters in body
Source Link
Greg Nisbet
  • 3.2k
  • 3
  • 32
  • 44

I have a python script that spawns a few subprocesses but never more than n at a time. I want to write a shell script to confirm that it has no more than n subprocesses at any given time, but also generally has n processes running. If I have the pid of the python program inside a shell script, how do I check the number of subprocesses that that pid currently has? E.g.

python script.py &
pid=$!
while true;true
do
    # do something that prints number of subprocesses of
    # the process $pid to stdout
    sleep 1
done

I have a python script that spawns a few subprocesses but never more than n at a time. I want to write a shell script to confirm that it has no more than n subprocesses at any given time, but also generally has n processes running. If I have the pid of the python program inside a shell script, how do I check the number of subprocesses that that pid currently has? E.g.

python script.py &
pid=$!
while true;
    # do something that prints number of subprocesses of
    # the process $pid to stdout
    sleep 1

I have a python script that spawns a few subprocesses but never more than n at a time. I want to write a shell script to confirm that it has no more than n subprocesses at any given time, but also generally has n processes running. If I have the pid of the python program inside a shell script, how do I check the number of subprocesses that that pid currently has? E.g.

python script.py &
pid=$!
while true
do
    # do something that prints number of subprocesses of
    # the process $pid to stdout
    sleep 1
done
Source Link
Greg Nisbet
  • 3.2k
  • 3
  • 32
  • 44

Finding number of child processes of particular process

I have a python script that spawns a few subprocesses but never more than n at a time. I want to write a shell script to confirm that it has no more than n subprocesses at any given time, but also generally has n processes running. If I have the pid of the python program inside a shell script, how do I check the number of subprocesses that that pid currently has? E.g.

python script.py &
pid=$!
while true;
    # do something that prints number of subprocesses of
    # the process $pid to stdout
    sleep 1