Help with schedule and pdf

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

Have you checked out this Rails tutorial:

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 :slight_smile:

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

ESPNDev

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

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.