Pgrep equivalent on windows


#1

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.


#2

On Feb 16, 10:32 am, “akbarhome” 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