Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Suppose I have starting my process like:

java -DSOME_STRING -jar foo.jar

Then on linux, I can use the following to find or kill this process:

pgrep -f SOME_STRING
pkill -f SOME_STRING

However this doesn't seem to work on cygwin. Can anyone suggest an alternative for these tools in cygwin?

share|improve this question
Doesn't work in what way? Doesn't kill the process, doesn't find the process to kill it? Gives an error? – EightBitTony Aug 24 '11 at 21:51
pgrep doesn't find the process. pkill doesn't kill the process. – toolkit Aug 25 '11 at 20:48

pkill and pgrep certainly exist within Cygwin, in the procps package (you can search cygwin packages here).

It appears to work for me,

tony:~$ nohup sleep 100983 &
[1] 5476
tony:~$ nohup: ignoring input and appending output to `nohup.out'
tony:~$ ps -ef | grep sleep
    tony    5476    2696   2  23:28:53 /usr/bin/sleep
tony:~$ pkill -f sleep
[1]+  Terminated              nohup sleep 100983


tony:~$ nohup sleep 837746 &
[1] 228
tony:~$ nohup: ignoring input and appending output to `nohup.out'
tony:~$ pgrep -f 837746
tony:~$ pkill -f 837746
[1]+  Terminated              nohup sleep 837746

Update: okay, tested with java. Executing java from the Cygwin command line does not result in the java string being placed into /proc/<pid>/cmdline, that just contains -bash. This appears to be a limitation of Cygwin.

tony:~$ java -Dsomething=valid -jar Captor.jar &
[1] 2700
tony:~$ ps -ef
    tony    4164       1   ?    Aug 21 /usr/bin/mintty
    tony    4676    4164   0    Aug 21 /usr/bin/bash
    tony    5776    4676   0    Aug 23 /usr/bin/ssh
    tony    5148       1   ?  23:53:03 /usr/bin/mintty
    tony    5332    5148   1  23:53:03 /usr/bin/bash
    tony    5816       1   ?  00:04:16 /usr/bin/mintty
    tony    5432    5816   2  00:04:16 /usr/bin/bash
    tony    2700    5432   2  00:04:34 /cygdrive/c/Windows/system32/java
    tony    2232    5432   2  00:04:39 /usr/bin/ps
tony:~$ pgrep -f something
tony:~$ cat /proc/2700/cmdline
tony:~$ cat /proc/2700/exename

I suspect therefore, the answer is you can't do this with a Cygwin tool, you would need a Windows specific tool.

share|improve this answer
Your example is substantially different than the one the OP is trying. You matched the name of the process rather than an arbitrary string in it's arguments. Can you test the latter and see if that works? – Caleb Aug 25 '11 at 5:21
seems to work fine – EightBitTony Aug 25 '11 at 7:06
It seems procps is not available for x64 cygwin. – thameera Oct 15 '13 at 5:57

The Cygwin utilities work like the Linux ones, but they only work on Cygwin processes. For Windows processes, you need to use Windows utilities, such as the ones from Sysinternals. PsKill can kill processes by name.

share|improve this answer
as can the native taskkill /f /im procname.exe – Marcos Feb 28 '12 at 12:51
ps also shows Windows processes with the -W switch – golimar Dec 11 '14 at 17:00

There is a procps package in cygwin that you can install to get the same functionality with the same commands.

share|improve this answer

Here are implementations of killall and pidof crafted for Cygwin. Depends on Python 2/

share|improve this answer
Welcome to Unix & Linux! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – slm Nov 25 '14 at 17: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.