Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number of cpu's

Status
Not open for further replies.

unixwhoopie

Programmer
May 6, 2003
45
US
How do I specify a process to use a specific number of CPU's?

Also, how can I kill all instances of a process for a specific user. Kill -9 PID would kill one instance but I want to kill all instances.

thanks
 
I don't know about that first question, but this might handle the latter:

kill -9 `ps -fu $USERNAME | grep $PROCNAME | grep -v "PID" | awk '{ print $2 }'`

You get to fill in the two variables. I'd put this in a script where to can do some sanity tests to prevent yourself from killing all the processes owned by "root" (or something equally disturbing).

"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
a little more ornate version ;)
Somewhere I meet such much better script,
but now can not remember where it was. Or did they include such command in the standard distribution of SCO 5.0.7 ?


:
# @(#) killusr.sh 1.2 92/06/20
#
# Cansel all processes of user
# Script is similar to killterm
#
# Parameter
# 1. user name
#
# Example
# $ killusr ivo
#
# Stiliyan Stankow, NOAC EOOD, tel. +359-2-8569094,
# stan@noac.biz
#
OK=0
FAIL=1

if [ $# -ne 1 ] # check parameters number
then
echo "Usage:" $0 "<name>"
exit $FAIL
fi
#
# Prevent root's suicide
#
if [ $1 = "root" ]
then
echo $0: name must be different from \"root\"
exit $FAIL
fi
#
# List ot all users processes
#
PROCESSES=`ps -ef | grep $1 | awk '$1 == "'$1'" {print $2}'`
#
# First signal to exit
#
kill $PROCESSES
#
# Then unconditional exit
#
kill -9 $PROCESSES
exit $O

 
well, at last found it - command to lock a process to CPU is lockpid

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top