shell - Selecting a value from output of ps -eaf -


suppose want select 6547 output of "ps -eaf" command, how do it? want select value , give "kill" command kill process.

root      6547     1  0 aug07 ?        00:00:00  root     14805     2  0 aug07 ?        00:00:00  root     17443 30043  0 16:21 pts/0    00:00:00  

you may have write small shell script - contain below option -

    pidlist=`ps -eaf | awk ' print $2'`       pid in pidlist       cmd="kill -9 $pid"       `$cmd`  

now based on critieria (like process name, user etc) can take action specific process. jist here use awk command exact column.


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -