# Cronjob for controller/action

**URL:** <https://www.ruby-forum.com/t/cronjob-for-controller-action/66245>\
**Category:** Rails\
**Created:** [August 24, 2006, 9:24am UTC](https://www.ruby-forum.com/t/cronjob-for-controller-action/66245 "2006-08-24T09:24:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@stian](https://www.ruby-forum.com/u/stian)\
**Post date:** [August 24, 2006, 9:24am UTC](https://www.ruby-forum.com/t/cronjob-for-controller-action/66245/1 "2006-08-24T09:24:37Z")

</div>

I’ve (currently) got some code, in it’s own action in a controller. It  
fetches email from imap and does all kinds of mojo with it. What I need  
to do is have this run via a cronjob every so and so many minutes. Now,  
currently, to run it I have to load [http://url/controller/action](http://url/controller/action) for  
that action. I want to run this silently in the backround on the server  
running the app, so that things will seem automatically.

I am considering running curl or wget in a cronjob, but are there any  
ways of doing this that are less caveman-ish?

---

<div class="post-metadata">

**Author:** ![stian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@stian](https://www.ruby-forum.com/u/stian)\
**Post date:** [August 24, 2006, 10:53am UTC](https://www.ruby-forum.com/t/cronjob-for-controller-action/66245/2 "2006-08-24T10:53:34Z")

</div>

Thats what you want:

[http://wiki.rubyonrails.com/rails/pages/RunnerScript](http://wiki.rubyonrails.com/rails/pages/RunnerScript)

---

<div class="post-metadata">

**Author:** ![stian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@stian](https://www.ruby-forum.com/u/stian)\
**Post date:** [August 24, 2006, 9:57am UTC](https://www.ruby-forum.com/t/cronjob-for-controller-action/66245/3 "2006-08-24T09:57:29Z")

</div>

You’ll need BackgrounDRb. If you’re german, i have written an article in  
my  
Blog just about that…  
[http://siebert-wd.de/articles/2006/08/16/regelmaessige-aufgaben-mit-backgroundrb-erledigen](http://siebert-wd.de/articles/2006/08/16/regelmaessige-aufgaben-mit-backgroundrb-erledigen)

2006/8/24, Stian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ways of doing this that are less caveman-ish?
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Michael S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

[www.siebert-wd.de](http://www.siebert-wd.de) - Gedanken lesen  
[www.stellar-legends.de](http://www.stellar-legends.de) - Weltraum-Browsergame im Alpha-Stadium

---

<div class="post-metadata">

**Author:** ![stian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@stian](https://www.ruby-forum.com/u/stian)\
**Post date:** [August 24, 2006, 4:14pm UTC](https://www.ruby-forum.com/t/cronjob-for-controller-action/66245/4 "2006-08-24T16:14:08Z")

</div>

scripts/runner – runner in the scripts directory is designed for  
recreating the rails environment to run rails code from a cron job,  
using all of your actions and etc. It has documentation in the usual  
places.

…  
…  
John B.
