Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to kill all find process with one command?

I do not want to kill each process as kill -9 25295 , kill -9 11994 , etc.. Rather, what I want is a simple way or command that kill all find process (my target is to perfrom this action on linux and solaris machines).

$ ps -ef | grep find 
root 25295 25290   0 08:59:59 pts/1 0:01 find /etc -type f -exec grep -l {} ; -print
root 11994 26144   0 09:04:18 pts/1 0:00 find /etc -type f -exec grep -l {} ; -print
root 25366 25356   0 08:59:59 pts/1 0:01 find /etc -type f -exec grep -l {} ; -print
root 26703 26658   0 09:00:05 pts/1 0:01 find /etc -type f -exec grep -l {} ; -print
share|improve this question
Having answered some of your questions and looked at may others I think that rather than an Q&A site it's time to talk to your manager about getting some basic education in the tools that you are using. – Iain Nov 25 '12 at 15:08
@lain this would be so old school! Neat! – kubanczyk Nov 25 '12 at 15:21
@lain what you think about the solution: fuser -k /tmp/ ? , (for linux and solaris ) – yael Nov 25 '12 at 15:48
up vote 5 down vote accepted

This will work on both Linux and Solaris and do precisely what you need:

pgrep -f 'find /etc'     # verify the listing before proceeding
pkill -9 -f 'find /etc'

In your situation, avoid killall. If you use it on Linux, sooner or later you will mistake the ssh sessions, run it on Solaris, creating unnecessary risk.

The -f option of pgrep/pkill means to match the entire command line. In case you need to match path of the program or script (/var/tmp/, this works if you had run it with the entire path. To be precise, you only need to escape the . so you need

pkill -9 -f '/var/tmp/test\.sh'

If you have run the same program as ./ you need to kill it as such. See -f option in ps.

share|improve this answer
Someday one of my coworker typed pkill -v foobar , thinking -v would increase verbosity;obviously it was on a production database server... Be careful everyone when you use pkill ;) – user130370 Nov 25 '12 at 15:24
Moreover, f is very close to v on the keyboard :) – kubanczyk Nov 25 '12 at 15:29
@kubanczyk what about fuser -k /tmp/ - I think is the best solution for linux and solaris - what you think ? – yael Nov 25 '12 at 15:46
@yael Never used fuser -k, because it does not support regular expressions as patterns. So I don't have any experience to share. – kubanczyk Nov 25 '12 at 16:34
not sure I try to kill the programs /tmp/ ( was 12 process running on both time ) , and fuser -k killed all ( process , , – yael Nov 26 '12 at 7:29

Use pkill find which is a variant of pgrep (process grep). On Linux, killall find would also work.

share|improve this answer
is it possible to kill proccess as script for example - pkill /var/tmp/ ? – yael Nov 25 '12 at 15:03

Yes, you can use the killall command

killall find 
share|improve this answer
But be very careful if going between Linux and Solaris, because at least on older versions of SunOS that I used, killall literally kills all processes, without the process matching and selection of the Linux version. – mattdm Nov 25 '12 at 14:42
As far as I know, this is still the case. – Sven Nov 25 '12 at 14:47
As a side note, the behavior is not nearly as funny on Solaris as on AIX. There, killall doesn't kill the current shell, so poor user has no idea how much fun just happened in the background :) – kubanczyk Nov 25 '12 at 15:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.