help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] The best way to monitor the number of concurrently runni


From: Aleksey Tsalolikhin
Subject: Re: [Help-bash] The best way to monitor the number of concurrently running processes forked by a main bash script ?
Date: Tue, 2 Apr 2019 04:35:07 -0700

ps will show you *all* the concurrently running processes that meet the
selection criteria -- it gets the info straight from the kernel.

And "watch" will run "ps" every 2 seconds (or as often as you configure it
to, watch can take an argument).  If getting a snapshot every 2 seconds is
not good enough, can you modify the child processes themselves to log when
they start and exit? Would that accomplish your purpose better?

On Tue, Apr 2, 2019 at 4:24 AM Peng Yu <address@hidden> wrote:

> Thanks. When the forked processes finish quickly, how can an external
> program ps keep track of them?
>
> On Tue, Apr 2, 2019 at 6:15 AM Aleksey Tsalolikhin <
> address@hidden> wrote:
>
>> Could you monitor by parent process id?
>>
>> The "ps" man page documents the parent process id option:
>>
>>        --ppid pidlist
>>               Select by parent process ID.  This selects the processes
>> with a
>>               parent process ID in pidlist.  That is, it selects processes
>>               that are children of those listed in pidlist.
>>
>> In other words, *something* must be creating these processes -- use the
>> PID of the *something*, and then you'll see all its children.  You could
>> run your "ps" command using the "watch" utility, and it would show you the
>> various children as they come and go.  (In your case, the PID of the bash
>> script that is forking the children.)
>>
>> Best,
>> -at
>>
>> On Sun, Mar 31, 2019 at 8:25 PM Peng Yu <address@hidden> wrote:
>>
>>> Hi,
>>>
>>> I want to monitor the number of concurrently running processes forked
>>> from a bash script. I could use things like top. But I don't think
>>> this can easily monitor the processes especially when processes finish
>>> very quickly. Probably a way that is native to bash might be better.
>>> Is it possible?
>>>
>>> What is the best way to monitor this info? Thanks.
>>>
>>> --
>>> Regards,
>>> Peng
>>>
>>>
>>
>> --
>> Achieve real learning.  Email address@hidden
>>
> --
> Regards,
> Peng
>


-- 
Achieve real learning.  Email address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]