Forum: Ruby on Rails ./script/runner in crontab -e gives "Mysql:Error"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2284a96344791b24e0496b68abfc2e88?d=identicon&s=25 Ashwin Kumar (ashwin)
on 2007-02-12 16:48
     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"
9d1310212bb9dfe69ee6b259c7945392?d=identicon&s=25 Sheldon Hearn (sheldonh)
on 2007-02-12 19:03
(Received via mailing list)
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.
6fa69a9590cfdeb3760beb157de8f8e0?d=identicon&s=25 Open Web20 (openweb20)
on 2007-02-12 19:53
(Received via mailing list)
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
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2007-02-12 20:42
(Received via mailing list)
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.
4a06d387963f5d1a0f49671153cb8866?d=identicon&s=25 Kyle Maxwell (Guest)
on 2007-02-13 02:04
(Received via mailing list)
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
2284a96344791b24e0496b68abfc2e88?d=identicon&s=25 Ashwin Kumar (ashwin)
on 2007-02-13 06:56
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
6fa69a9590cfdeb3760beb157de8f8e0?d=identicon&s=25 Open Web20 (openweb20)
on 2007-02-16 06:07


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.
This topic is locked and can not be replied to.