diff --git a/Utilities/Tools/jobutils2.sh b/Utilities/Tools/jobutils2.sh index ba96b97da090b..b7c8466f54313 100644 --- a/Utilities/Tools/jobutils2.sh +++ b/Utilities/Tools/jobutils2.sh @@ -395,10 +395,13 @@ getNumberOfPhysicalCPUCores() { fi else # Do something under GNU/Linux platform - CORESPERSOCKET=`lscpu | grep "Core(s) per socket" | awk '{print $4}'` - SOCKETS=`lscpu | grep "Socket(s)" | awk '{print $2}'` + # + # Gets the cores per socket by counting unique cores on socket 0. + # Gets sockets by counting unique socket ids. The grepping is done in any case to avoid matching comments. + CORESPERSOCKET=$(lscpu -p=cpu,socket | grep "^[0-9]\+,0" | sort | uniq | wc -l) + SOCKETS=$(lscpu -p=socket | grep -e "^[0-9]" | sort | uniq | wc -l) fi - N=`bc <<< "${CORESPERSOCKET}*${SOCKETS}"` + N=$((${CORESPERSOCKET}*${SOCKETS})) echo "${N}" }