I'm putting in a reaper line into a rake task to kill some additionally spawned ruby tasks as they somehow creep up on occasion.
system "ps aux | grep 'namespace:taskname' | grep ruby | grep -v grep | awk '{print $2}' | xargs kill -9; echo 'Reaped old namespace:taskname processes.'"
I'd like to add grep -v $PID_OF_CURRENT_TASK
in that just to be sure I don't kill the current task that's running as well.
How do I get that PID?
You get the current PID in Ruby with Process.pid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With