kill all user processes

Hi there, i've been searching all over and i thought i had understood the way i should go to kill all the processes related to a user. But i'm getting more confused then i was.
By lunch time i have to make a database backup, and for that all the users shoul logout. The problem is that many users don't have the trouble logging out , so before i start the backup i have to kill them all. I've tryed some scripts , and tryed to adapt them to my needs, but all that i found would kill by process name , or using the pid.
I need some script that would ask me for the user to kill , and given the username it would kill all the processes running by tht user.
How can i do this?

i was trying to use this

printf "\n\nUsername to kill?"
read nUsername

[ "$nUsername" ] || exit

ps -u $nUsername | awk -v nUid="nUid" '
{
if ( $1 == nUid )
kill -9 $2
}'

sorry, no great knowleage about scripting
thanks

Try something like:

echo `ps -fu $User | awk 'NR != 1 {print $2}'`

Once you're sure that you're eching the right stuff, replace the echo with kill.

And don't do a kill -9 right off the bat like that. First take the default of -15 and give the processes a few seconds to gracefully shutdown. If any are left, then you can resort to "kill -9". This is especially important in a database environment.

thanks Perderabo

it works wonderfully

I wanted to comment that this is perfect but I found out that you need to be in bash to run it

try this. on Solaris this should kill Idle user

who -u | grep 'UserName' | awk '{print $7}' | xargs -i kill -9 {}