I am writing a tiny Sinatra application and I want to host it on Heroku for simplicity. But I have a task that cuts off some sites and adds some data to my database every hour. Currently, it is simply written as a ruby script that must be executed. What Heroku has a rake based cron job . Now, if it was a rails application, I could easily do it, but I want to avoid clutter for something as simple as this.
Is there any way to avoid this? Or do I need to rake also with my application?
Thank.
Eric
You need a Rakefile, for example:
desc "This task is called by the Heroku cron add-on" task :cron do # Do something end
Heroku periodically launches rake cron in your application, depending on whether you selected cron add-on both hourly and daily.
You need to check out Rufus. Rufus is your friend. Rufus will be your crontab while your application is downloaded.
I have not tried this material on Heroku, but try and answer us.
http://codex.heroku.com/past/2010/4/15/rufus_scheduler_for_my_tiny_sinatra_apps/
Why is Rufus cool? Well check it out, it's clean :)
$ sudo gem install rufus-scheduler require 'rubygems' require 'rufus/scheduler' scheduler = Rufus::Scheduler.start_new scheduler.cron '00 23 30 * *' do # Run every 30 days at 23h00m # ...your magic code goes here... end
, , .
, Rails, Rakefile .
Rakefile
, .
!