set cpu affinity #!/bin/sh #setaff HOLD1=/tmp/hold1.$$ PROCESS=$1 CPUID=$2 usage() { #usage() echo "Usage:`basename $0` process_name cpuid" exit 1 } if [ $# -ne 2 ];then usage fi case $1 in *) #grep the process,do not include our script in the output from ps #extract fields 1 and 6,redirect to a temp file #ps x|grep $PROCESS|grep $-v $0|awk `{print $1"/t" $6}`>$HOLD1 #ps -eo pid,psr,args | grep $PROCESS | grep -v "grep" | gawk '{print $1"/t" $3}'>$HOLD1 ps -eo pid,psr,args | grep $PROCESS | grep -v "grep"| grep -v $0 | gawk '{print $0}'>$HOLD1 ;; esac #is the file there?? if [ ! -s $HOLD1 ];then echo "No processes found ..sorry" exit 1 fi #read in the contens from the temp file and display the fields while read LOOP1 LOOP2 do echo $LOOP1 $LOOP2 done <$HOLD1 echo -n "Are these processes to be set affinity?[Y..N]" read ANS case $ANS in Y|y) while read LOOP1 LOOP2 do # echo $LOOP1 taskset -c -p $2 $LOOP1 done <$HOLD1 rm /tmp/*.$$ ;; N|n);; esac