0

I recently made a Ruby gem called dvi_scrape for a new Rails web site that I'm working on. The dvi_scrape gem downloads web pages, scrapes financial data from them, process the data, and outputs the results to a Postgres database.

I'm able to get the Ruby command Dvi_scrape.dopeler to work as expected when executed manually. However, I'm unable to get it to work as expected when executed through cron.

How do I get this to work from cron on my WebFaction account?

The source code of the Rails site I'm working on this . The source code of the dvi_scrape gem is at this place .

I understand that config/schedule.rb is where you specify what scripts need to be run and at what time intervals. config/environment.rb is where you specify the environment. config/deploy.rb is where you specify what happens when you enter "cap deploy".

Are there any good examples of scripts that execute commands from certain gems at regular intervals? Please point me to some good examples on GitHub.

Thirumalai murugan
  • 5,698
  • 8
  • 32
  • 54
jhsu802701
  • 573
  • 1
  • 7
  • 23

1 Answers1

0

I don't have any "good examples on GitHub", but...

Assuming you have the gem installed into some specific web application (ie, you followed WebFaction's documentation for installing gems), you probably need to set some environment variables to make it usable when running from cron.

Try setting them in your cron job, like this (my example uses a 10-minute cron interval, change it to whatever you need):

*/10 * * * * GEM_HOME=$HOME/webapps/yourapp/gems RUBYLIB=$HOME/webapps/yourapp/lib PATH=$HOME/webapps/yourapp/bin your_command_here

Hope that helps!

Sean F
  • 817
  • 9
  • 20