# Pgrep equivalent on windows

**URL:** <https://www.ruby-forum.com/t/pgrep-equivalent-on-windows/85840>\
**Category:** Ruby\
**Created:** [February 16, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/pgrep-equivalent-on-windows/85840 "2007-02-16T18:36:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rinda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rinda](https://www.ruby-forum.com/u/rinda)\
**Post date:** [February 16, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/pgrep-equivalent-on-windows/85840/1 "2007-02-16T18:36:40Z")

</div>

Hi, I have this code need to be translated to windows machine:

`kill #{`pgrep -f optimize\_jobs.rb`.chomp}`  
exec(“ruby -C#{RAILS\_ROOT}/public/files optimize\_jobs.rb &”) if fork  
== nil

The second line has been translated successfully as:  
require “win32/process”  
exec(“ruby -C#{RAILS\_ROOT}/public/files optimize\_jobs.rb &”) if  
Process.fork == nil

But what about first line? Anybody know how to translate that to  
windows machine (Windows XP Home if that matters)?

Thank you.

---

<div class="post-metadata">

**Author:** ![rinda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rinda](https://www.ruby-forum.com/u/rinda)\
**Post date:** [February 16, 2007, 7:05pm UTC](https://www.ruby-forum.com/t/pgrep-equivalent-on-windows/85840/2 "2007-02-16T19:05:42Z")

</div>

On Feb 16, 10:32 am, “akbarhome” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But what about first line? Anybody know how to translate that to  
> windows machine (Windows XP Home if that matters)?
> 
> Thank you.

If you’re looking for a pure Ruby solution you can use sys-proctable,  
and roll your own version of pgrep. Otherwise, you’ll need to install  
some third party tool.

Regards,

Dan
