# Help with schedule and pdf

**URL:** <https://www.ruby-forum.com/t/help-with-schedule-and-pdf/132515>\
**Category:** Rails\
**Created:** [March 20, 2008, 11:17pm UTC](https://www.ruby-forum.com/t/help-with-schedule-and-pdf/132515 "2008-03-20T23:17:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 20, 2008, 11:17pm UTC](https://www.ruby-forum.com/t/help-with-schedule-and-pdf/132515/1 "2008-03-20T23:17:47Z")

</div>

I would like to be able to do this: I want to generate a pdf all Fridays  
at an specific time. This pdf should be stored in an specific place too.  
So I think something that makes the application able to look at what  
time is it and do this pdf when this time arrives, even if no one is  
using the application. I already know how to make the pdf and how to  
store it, but I need help with generating this pdf at an specific time,  
without any user pressing a button.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 20, 2008, 11:48pm UTC](https://www.ruby-forum.com/t/help-with-schedule-and-pdf/132515/2 "2008-03-20T23:48:34Z")

</div>

On 20 Mar 2008, at 23:17, John S. wrote:

> I would like to be able to do this: I want to generate a pdf all  
> Fridays  
> at an specific time. This pdf should be stored in an specific place  
> too.  
> So I think something that makes the application able to look at what  
> time is it and do this pdf when this time arrives, even if no one is  
> using the application. I already know how to make the pdf and how to  
> store it, but I need help with generating this pdf at an specific  
> time,  
> without any user pressing a button.

A few options:

- Cron tab and script/runner
- BackgroundRB and its scheduler
- Ruby thread with sleep

The subject has come up recently in a slightly different context so if  
you google around on the keywords mentioned above, you should find  
everything you need.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 20, 2008, 11:50pm UTC](https://www.ruby-forum.com/t/help-with-schedule-and-pdf/132515/3 "2008-03-20T23:50:20Z")

</div>

Have you checked out this Rails tutorial:

[http://wiki.rubyonrails.org/rails/pages/HowToRunBackgroundJobsInRails](http://wiki.rubyonrails.org/rails/pages/HowToRunBackgroundJobsInRails)

Line 4 says: “Alternately can I write a background job that’ll, for  
example, spit out a nicely formatted text file every night at 2:00  
AM?” Seems like what you’re talking about 🙂

There’s a bunch of resources out there for learning to write CRON  
jobs. Check 'em out.

ESPNDev

On Mar 20, 3:17 pm, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 21, 2008, 10:57am UTC](https://www.ruby-forum.com/t/help-with-schedule-and-pdf/132515/4 "2008-03-21T10:57:59Z")

</div>

> - BackgroundRB and its scheduler
> - Ruby thread with sleep

These are of course the preferred options (in the order they have been  
posted by Peter) but if none of this will work in your hosting  
environment you might have to simply wait for the next hit on your  
application and then if current\_time \>  
time\_at\_which\_pdf\_should\_be\_generated you run a background job to  
generate it. I remember that a few years ago there were also plenty of  
serivces on the mighty interweb which called a specified URL at a given  
time (sort of a remote cron job if you will). This might be best if the  
above three won’t work.

Cheers,  
Niels.
