./script/runner in crontab -e gives "Mysql:Error"

 Hi ,
     I have no freaking clue what to do with the ./script/runner.
     I wanna send emails by using ./script/runner
     such that i use crontab for it .................
  1.  I tried setting out the varible of mysql
              "SET @@NET_READ_TIMEOUT=400;" as per
               http://bugs.mysql.com/bug.php?id=1370)
     But no use i still get the same error.
    
  2.  I'm  using lightpd web server.
     Does ./script/runner has anything to do with webserver
     if yes plz tell me how to use ./script/runner with lighttpd
    
  3. I dont knw y validates_captcha error is coming in the log …
    I’ve validates_captcha rule in user model but how does that cause an
    error.
    or can i just ignore this error???

  4. Are there any alternatives ( I heard BackgroundDRB )
    What is latest stable production release for BackgroundDRB …
    Does it do the CRON functionality as well… or
    still needs to plug to crontab…

    Any help is appreciated!!!

------------------------ THis is model method i’m using ------------

class Pop < ActiveRecord::Base

def self.get_test_emails_count
return Pop.find_by_sql([‘select count(p_user_id),p_user_id from
pops group by p_user_id having count(*) > 3’])
end

def self.test_emails

@evalsd = Pop.get_test_emails_count

for eval in @evalsd

@user = User.find_by_sql([‘select * from users where id =
?’,eval.p_user_id])

UserNotify.deliver_test_emails(@user)

end

end

---------------------------------------Development.log

ERROR: Could not load RMagick. CAPTCHA image challenge not available.
(validates_captcha)

Pop Load (0.000000) Mysql::Error: Lost connection to MySQL server
during query: select count(p_id),p_id from pops group by p_id having
count(*) > 3

ERROR: Could not load RMagick. CAPTCHA image challenge not available.
(validates_captcha)

Pop Load (0.000000) Mysql::Error: Lost connection to MySQL server
during query: select count(p_id),p_id from pops group by p_id having
count(*) > 3

---------------------my crontab -e is ------------------------------

*/1 * * * * ruby /home/jodiks/workspace/govantra/script/runner -e
development “Pop.test_emails”

Have you tried running that job from the command-line, as the user
whose crontab the job is executed?

If that works, it has to be an environmental issue. For example, if
you’re using Gentoo Linux, interactive shells will have RUBYOPT=-
rauto_gem in the environment, which causes rubygems to be required
automatically, for any ruby script. However, that environment
variable isn’t set in a cron job.

Good luck.

Ciao,
Sheldon.

Ashwin,

If you want Cron functionality for Rails, then you should look at

http://rails.co.za/articles/2006/06/03/using-railscron

We are using Rails Cron successfully in Ajuby (
http://ajuby.openapp.org)
toolkit, as our scheduler (on which we are running Feed aggregation and
Feed
notification delivery jobs).

Hope that helps

-Rajesh

In direct answer to your question, you should be able to use script/
runner from cron. Here’s how I do it:

  1. log in as the user who owns the crontab
  2. cd /to/someplace/other/than/your/rails/directory
  3. /full/path/to/rails/root/script/runner -e production “Model.method”

If (3) works as expected, then simply copy that line into your
crontab. Note two things: You MUST specify your environment or live
with the default which is, I believe, development; and you should
quote the method call.

If it doesn’t work, look at your production.log and your various
error logs. Don’t look at the Web server logs, as there is no
interaction with your Web server. You may get a log entry if you have
invalid database login credentials.

Hope this helps.

Rajesh Shetty wrote:

Ashwin,

If you want Cron functionality for Rails, then you should look at

http://rails.co.za/articles/2006/06/03/using-railscron

We are using Rails Cron successfully in Ajuby (
http://ajuby.openapp.org)
toolkit, as our scheduler (on which we are running Feed aggregation and
Feed
notification delivery jobs).

Hope that helps

-Rajesh

I’ve already looked at it.
Its a broken url.
Can u please tell me check out command for it or download link for l

Regards,
Ashwin

Couple notes.

  1. RailsCron is no longer supported by the author (that’s me!).
  2. I wrote daemon_generator, as the simplest possible background rails
    service. Typically, the example workflow is something like
    “do_my_service;sleep 10”. Daemon_generator provides the startup
    scripts, monitoring, logging, etc. So you don’t get cron-like
    scheduling, but I don’t think that’s what you want anyways.

-Kyle

Ashwin Kumar wrote:

Rajesh Shetty wrote:

Ashwin,

If you want Cron functionality for Rails, then you should look at

http://rails.co.za/articles/2006/06/03/using-railscron

We are using Rails Cron successfully in Ajuby (
http://ajuby.openapp.org)
toolkit, as our scheduler (on which we are running Feed aggregation and
Feed
notification delivery jobs).

Hope that helps

-Rajesh

I’ve already looked at it.
Its a broken url.
Can u please tell me check out command for it or download link for l

Regards,
Ashwin

Ashwin,

Thats interesting with Rails plugins, As Kyle himself said above,
RailsCron no longer supported , But we still use it in Ajuby toolkit. So
assuming its not available anymore, and you still wants to use it, I
would say go ahead and download Ajuby toolkit from
http://ajuby.openapp.org and once you download this, under
vendor/plugins you will find rails_cron and that should solve your
problem. Thats the only way I can think of for you to get a handle on
rails_cron.
Meanwhile look into backgroundrb http://backgroundrb.rubyforge.org/
and looks like lot of people are happily using this as background
processor. We will be looking into this slowly to move away from
rails_cron.