# Update data via cron?

**URL:** <https://www.ruby-forum.com/t/update-data-via-cron/116844>\
**Category:** Rails\
**Created:** [October 10, 2007, 11:30am UTC](https://www.ruby-forum.com/t/update-data-via-cron/116844 "2007-10-10T11:30:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Raven](https://www.ruby-forum.com/u/Raven)\
**Post date:** [October 10, 2007, 11:30am UTC](https://www.ruby-forum.com/t/update-data-via-cron/116844/1 "2007-10-10T11:30:15Z")

</div>

Hi!

I’m building a small site and I wish to fill the data in the database  
nightly via cron. What is best practice here? Do I:

1. have cron do a normal web request to /nightRunner/doIt?
2. build a maintenance script and place it somewhere (where?) that  
have access to the models and database and call it via script/runner?

Thanks.

---

<div class="post-metadata">

**Author:** ![Raven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Raven](https://www.ruby-forum.com/u/Raven)\
**Post date:** [October 10, 2007, 11:33am UTC](https://www.ruby-forum.com/t/update-data-via-cron/116844/2 "2007-10-10T11:33:47Z")

</div>

On 10 Oct 2007, at 10:29, Raven wrote:

> Hi!
> 
> I’m building a small site and I wish to fill the data in the database  
> nightly via cron. What is best practice here? Do I:
> 
> 1. have cron do a normal web request to /nightRunner/doIt?
> 2. build a maintenance script and place it somewhere (where?) that  
> have access to the models and database and call it via script/runner?

1. urgh.
2. Yes. we typically have a cron\_jobs folder with (you guessed it)  
cron jobs

Sticking

#!/usr/bin/env ruby  
require File.dirname( **FILE** ) + ‘/…/config/boot’  
require File.dirname( **FILE** ) + ‘/…/config/environment’  
ActiveRecord::Base.establish\_connection

at the top should get all the rails stuff setup for you

Fred

---

<div class="post-metadata">

**Author:** ![Raven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Raven](https://www.ruby-forum.com/u/Raven)\
**Post date:** [October 10, 2007, 2:33pm UTC](https://www.ruby-forum.com/t/update-data-via-cron/116844/3 "2007-10-10T14:33:05Z")

</div>

Or you can run your cron script with script/runner

On 10/10/07, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 1. build a maintenance script and place it somewhere (where?) that  
> > require File.dirname( **FILE** ) + ‘/…/config/boot’  
> > require File.dirname( **FILE** ) + ‘/…/config/environment’  
> > ActiveRecord::Base.establish\_connection
> 
> at the top should get all the rails stuff setup for you
> 
> Fred
> 
> >

–  
Cheers!

- Pratik  
[http://m.onkey.org](http://m.onkey.org)
