Recently I wan working on a script which automatically starts the set of scripts in background. When I wanted to stop those scripts, I have written a small command which kills all processes at one shot which are matching the pattern. Here is the command
kill -9 `ps -eaf|grep "stat.sh"|grep -v grep | awk '{print $2}'`
Here
stat.sh ==> is the pattern.
grep -v grep ==> avoid grep's process id
awk '{print $2}'` ==> prints second argument
I use this often in unix/linux.
No comments:
Post a Comment