Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to write a script to do something that I repetitively do everyday, and that for it to be useful I need the value given by the command nproc.

The problem is that nproc on bash returns my number of cores just fine, but when i call python and inside in import os and then do os.system("nproc"), it first gives me the correct value, and later a zero value.

Why this happen and how can I fix it?

Edit: Also tried the method "lscpu | grep CPU | awk 'NR==2 {print $2}'" And same thing happened...

share|improve this question

closed as off-topic by Javier Rivera, Avinash Raj, karel, TrailRider, Braiam Feb 5 at 13:17

  • This question does not appear to be about Ubuntu within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
I was able to pull it out with the answers from: stackoverflow.com/questions/3791465/… –  Henrique Ferreira Feb 3 at 5:50
    
3  
General programing question already answered in Stack Overflow. –  Javier Rivera Feb 4 at 7:56

Browse other questions tagged or ask your own question.