title: Ruby on rails: How to run a background task automatically when the server starts?
body: <p>I have created a rails application that runs a background process. It pings a server periodically and displays a graph for the response time. For this I am using a gem called crono. I am starting the task from the command line using 'bundle exec crono'.</p>
  
  <p>How can I run the background process automatically when the rails server starts without having to start it from the command line?</p>
  
  <p>Also, is there a way to automatically refresh the page periodically so that it displays an updated graph?</p>
  
  <p>Edit: This application will be deployed to production.<br>
  Edit: I still couldn't get this to work. Here's the folder structure: </p>
  
  <hr>
  
  <blockquote>
    <p>application/config/<br>
        ping_job.rb<br>
        cronotab.rb</p>
  </blockquote>
  
  <p>cronotab uses 'crono' gem to execute the task inside ping_job.rb every 5 seconds.</p>
  
  <blockquote>
    <p>require 'typhoeus'<br>
    class PingJob<br>
    &#160;&#160;def peform<br><br>
    &#160;&#160;&#160;#task definition goes here.<br><br>
    &#160;&#160;end<br>
    end</p>
  </blockquote>
  
  <p>I want to run the task defined in ping_job.rb automatically when the server starts. I am thinking of using whenever gem. Any and all suggestions is welcome.</p>