Re: OT: Howto to capture taskset output command

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



From: C. L. Martinez <carlopmart@xxxxxxxxx>

> I am trying to set processor affinity for a specific process using a
> shell script without result. Script:
> 
> #!/bin/sh -x
> 
> cpu_affinity_ok="2"
> cpu_affinity="taskset -p -c `cat /tmp/test.pid` | awk '{print 
> $6}'"
> 
> if [ -f /tmp/test.pid ]; then
>     if [ "$cpu_affinity" == "$cpu_affinity_ok" ]; then
>        exit 0
>      else
>         taskset -p -c 2 `cat /tmp/test.pid`
>      fi
> fi
> 
> This script doesn't works:
> 
> As you can see, function compare under "if" statement doesn't 
> works ...

This works for me:

function cpu_affinity() {
  taskset -p -c $1 | awk ' { print $6 } '
}

and

PID=`cat /tmp/test.pid`
if [ $(cpu_affinity $PID) -eq $cpu_affinity_ok ]; then

JD
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos





[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux