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

Re: How to `echo' the core # a bash script is running on?



* Andrei POPESCU wrote on 2014-02-09 at 19:36 (+0200):
> On Du, 09 feb 14, 18:14:29, Mathias Bauer wrote:
> > * Marco Ippolito wrote on 2014-02-09 at 13:24 (+0100):
> >
> > > How can I `echo', in `bash', the core # the current script
> > > is running on?
> >
> > you can try
> >
> >   $ grep ^processor /proc/cpuinfo | wc -l
>
> I think the OP wants to know on which particular core the
> script is running on.

I read "...core #..." as "...the number of cores on the
machine...".  Hm, yes, your interpretation is also possible.

Anyway, is it possible at all to determine the particular core
the current script is running?  I mean, there is one underlying
shell process.  But if the script uses a pipeline, a command that
is not builtin in bash, or just a simple while loop, etc. there
will surely be further (sub)processes.  I doubt they are all
running on the same core.  Therefore the particular core a shell
script is running on doesn't seem to be sensible?

Perhaps the OP wants to use taskset, cpuset and the like.  But
without providing much more details...

Regards,
Mathias


Reply to: