How to run a long-running job on an Amazon EC2 instance in Rails?

advertisements

I'm using resque gem, and I'm running the jobs through the following command:

rake resque:work QUEUE='*'

But the problem is: As my SSH connection with remote server gets disconnected, or I close the SSH session window that is running the process rake resque:work QUEUE='*', it stops running the job.

I'd like to have a way in which the job will run independently: no need to remain connected with through SSH. Is there a way, or should I follow this procedure to accomplish what I require?


For this you can run rake task in background. There are multiple ways to accomplish this. Two of them are here:

  1. Using daemon you can run a rake task in background. Here is link for what is daemon. Here is link, How to achieve this for rails rake tasks. Appending & to rake task is my preferred way.

  2. Implement a cron to run rake task individually.