3

I set a cron job to run a rake task. This task will do somethings, such as send a post request...

If timeout, process cannot finished normally. How to set a timeout time, if this time is surpassed,

then the rake task will exit.

pangpang
  • 8,581
  • 11
  • 60
  • 96

1 Answers1

3
require 'timeout'
status = Timeout::timeout(5) {
  # Something that should be interrupted if it takes too much time...
}
anton-z
  • 104
  • 4