I’m trying to set up a cron job with a runner that calls a method in one
of my models. I’m using javan’s whenever gem to do this and I’m running
CentOS on my server. Whenever the cron executes though I’m getting the
following error:
`require’: no such file to load – rubygems (LoadError)
The method uses the ‘mail’ and ‘nokogiri’ gems. I tried cron again by
including ‘require rubygems’ as well, but that doesn’t seem to help. I
suspect that it may be a problem with my path variables.
Any advice on how to fix this though? Thanks, any help would be really
appreciated.
I’m trying to set up a cron job with a runner that calls a method in one
of my models. I’m using javan’s whenever gem to do this and I’m running
CentOS on my server. Whenever the cron executes though I’m getting the
following error:
cron by default uses a more restrictive set of environment variables.
You may need
to tweak the jobs settings so that everything is set correctly in the
variables (from what
I can remember off the top of my head):
PATH (make sure cron can find all the binaries it needs),
LANG (make sure the encoding is the same, en_US is crons default
IIRC, and it may need en_US.utf8),
RUBYOPT,
RAILS_GEM_VERSION,
GEM_HOME,
GEM_PATH
It may be a good idea to run a junk cron job in there to just run the
‘set’ command
and dump it out to a file so you can see what environment cron has
when trying to
run by default.
PATH (make sure cron can find all the binaries it needs),
LANG (make sure the encoding is the same, en_US is crons default
IIRC, and it may need en_US.utf8),
RUBYOPT,
RAILS_GEM_VERSION,
GEM_HOME,
GEM_PATH
It may be a good idea to run a junk cron job in there to just run the
‘set’ command
and dump it out to a file so you can see what environment cron has
when trying to
run by default.
-J
Thanks a lot, Jason. Yeah, I figured it was my path and I also noticed
that ‘which ruby’ showed that I was using two different locations, so I
put in my $PATH at the top of my cron and that fixed the LoadError.
I’m not getting that anymore, however now I’m getting the following
SQLException when using cron:
runner.rb:50:in `eval’: SQLite3::SQLException: no such table: users:
SELECT “users”.* FROM “users” (ActiveRecord::StatementInvalid)