Kill All Processes by User in UNIX

An application user asks to kill all the processes under their application account. When you checked on the box itself you saw a lot of processes and killing them one by one would take forever.

Here you could check the user’s processes:

root@solaris# ps -u [username] -o user,pid,ppid,pcpu,vsz,tty,args

usage: ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ]
[ -u userlist ] [ -U userlist ] [ -G grouplist ]
[ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
'format' is one or more of:
user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid
pri opri pcpu pmem vsz rss osz nice class time etime stime
f s c lwp nlwp psr tty addr wchan fname comm args projid project pset

This is the way to kill all the processes by a certain user

root@solaris# kill -9 `ps -u [username] -o pid`

Hopefully this could help my fellow UNIX SysAdmins and alike.

See you on my next note!!!