How to Run Scheduled Tasks?

Hi,

I’m coding a scheduling application where reminders are sent out to
users at date-times specified by the users. What’s the best way to do
this?

Thanks! :slight_smile:

Bob

I’m coding a scheduling application where reminders are sent out to
users at date-times specified by the users. What’s the best way to do
this?

On a *nix server, you’ll want to use cron. On a Windows server, you
might be able to use Scheduled Tasks.

An often-adopted approach is to create a “maintenance/scheduling”
controller whose actions are invoked by wget through cron. The following
example crontab line will hit your controller hourly:

0 * * * * wget -O - -q http://www.domain.tld/maintenance

Roderick


Nedforce Informatica Specialisten B.V.
http://www.nedforce.nl
+31 (0)53 4500225

Roderick van Domburg wrote:

I’m coding a scheduling application where reminders are sent out to
users at date-times specified by the users. What’s the best way to do
this?

On a *nix server, you’ll want to use cron. On a Windows server, you
might be able to use Scheduled Tasks.

There used to be a rails_cron plugin as a cross-platform, Rubyish
solution for this need. Sadly, it was abandoned:

http://kylemaxwell.typepad.com/everystudent/2006/09/railscron_depre.html

You may want to check out BackgroundRb:

http://backgroundrb.rubyforge.org/

-Adam

I’m coding a scheduling application where reminders are sent out to
users at date-times specified by the users. What’s the best way to
do

this?

On a *nix server, you’ll want to use cron. On a Windows server, you
might be able to use Scheduled Tasks.

As suggested above, you can use Unix cron / Windows scheduled tasks to
run a Rails rake task.

That is a better option.
And another PHP-ism flies out the window…

Roderick


Nedforce Informatica Specialisten B.V.
http://www.nedforce.nl
+31 (0)53 4500225

Ben wrote:

cd /path/to/rails/application
rake <task_name> RAIL_ENV=production

Oops, I made a small typo, that should be RAILS_ENV=production

Roderick van Domburg wrote:

I’m coding a scheduling application where reminders are sent out to
users at date-times specified by the users. What’s the best way to do
this?

On a *nix server, you’ll want to use cron. On a Windows server, you
might be able to use Scheduled Tasks.

As suggested above, you can use Unix cron / Windows scheduled tasks to
run a Rails rake task.

http://www.fallenrogue.com/articles/168-Script-vs-Rake

Create a new file in lib/tasks with the extension .rake with your
required task. To invoke it simply cd to your rails directory and run
rake with your task name (optionally specify the Rails environment).
The code inside the task will have full access to your Rails
environment including models.

cd /path/to/rails/application
rake <task_name> RAIL_ENV=production

Ben

Roderick van Domburg wrote:

On Windows, I use PyCron for this and it’s not bad. Just search Google
for it.

Cheers
Mohit.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs