# Daemons gem vs cron jobs to execture rails code

**URL:** <https://www.ruby-forum.com/t/daemons-gem-vs-cron-jobs-to-execture-rails-code/149605>\
**Category:** Rails\
**Created:** [September 26, 2008, 6:13pm UTC](https://www.ruby-forum.com/t/daemons-gem-vs-cron-jobs-to-execture-rails-code/149605 "2008-09-26T18:13:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hotspoons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e68b1a/32.png) [@hotspoons](https://www.ruby-forum.com/u/hotspoons)\
**Post date:** [September 26, 2008, 6:13pm UTC](https://www.ruby-forum.com/t/daemons-gem-vs-cron-jobs-to-execture-rails-code/149605/1 "2008-09-26T18:13:11Z")

</div>

I need help understanding the pros and cons of these 2 facilities.

Am I correct in assuming that this daemon by definitive runs in the  
rails environment, whereas a cron will have to load up a rail  
environment each time and thus consumer for more resources than the  
daemons gem?

---

<div class="post-metadata">

**Author:** ![hotspoons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e68b1a/32.png) [@hotspoons](https://www.ruby-forum.com/u/hotspoons)\
**Post date:** [September 26, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/daemons-gem-vs-cron-jobs-to-execture-rails-code/149605/2 "2008-09-26T18:21:24Z")

</div>

On Sep 26, 5:13 pm, Rich S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I need help understanding the pros and cons of these 2 facilities.
> 
> Am I correct in assuming that this daemon by definitive runs in the  
> rails environment, whereas a cron will have to load up a rail  
> environment each time and thus consumer for more resources than the  
> daemons gem?

The difference is that a daemon is a long running process (ie  
initialisation happens once), whereas a cronjob is something that is  
launched repeatedly.  
So yes, a cronjob spends more time loading rails/your app over and  
over again, but a daemon will set on however much memory it needs all  
the time, whereas a cronjob will return those resources when it has  
finished. To an extent the trade off depends how often you want to  
perform your task.

Fred

---

<div class="post-metadata">

**Author:** ![hotspoons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e68b1a/32.png) [@hotspoons](https://www.ruby-forum.com/u/hotspoons)\
**Post date:** [September 26, 2008, 6:31pm UTC](https://www.ruby-forum.com/t/daemons-gem-vs-cron-jobs-to-execture-rails-code/149605/3 "2008-09-26T18:31:24Z")

</div>

nice summary – thanks!

---

<div class="post-metadata">

**Author:** ![hotspoons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e68b1a/32.png) [@hotspoons](https://www.ruby-forum.com/u/hotspoons)\
**Post date:** [September 26, 2008, 6:56pm UTC](https://www.ruby-forum.com/t/daemons-gem-vs-cron-jobs-to-execture-rails-code/149605/4 "2008-09-26T18:56:07Z")

</div>

Rich (and Fred)

On 26-Sep-08, at 12:19 PM, Frederick C. wrote:

> > daemons gem?  
> > Fred  
> > The daemons gem (and plugin) can be run as per a cron-job (with  
> > regularity) - I think (?) it loads up the environment every time - but  
> > has a babysitting/launcher process to keep an eye on the spawn(ed).

FWIW, I found this gem to be problematic (would stop running for no  
apparent reason), and monit had troubles restarting it. I’ve gone back  
to cron to do regular tasks.

(wasn’t sure if you were talking about Daemons in general or the gem/  
plugin. Fred’s description is correct with regard to daemons in  
general, and so the gem might be misnamed as it seems to be a railscron)

Jodi
