Search code examples
ruby-on-railsengineyard

Cron job on EngineYard


Can someone give me direction how to setup a cron job on EngineYard that checks the database every x minutes and performs a task on them?

Most basically, I'm not sure how to have the script access the database.


Solution

  • One way to do this would be to first create a rake task for your application. With a rake task you automatically have access to your environment database and code structure.

    Then you can schedule the task as a cron job in the Engine Yard Admin page. You find it in Dashboard > More Options > Crontabs

    The command to execute a rake task is like this:

    cd /data/YourAppName/current && RAILS_ENV=production rake namespace:task