Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 1.74 KB

README.rdoc

File metadata and controls

47 lines (31 loc) · 1.74 KB

TaskScheduler

TaskScheduler provides a means to run rake tasks on a schedule triggered by a simple crontab entry. You build your rake tasks in the usual way and create a schedule for TaskScheduler to trigger them.

Installation

Set up the Gemfile

Include the TaskScheduler gem in your Rails application Gemfile:

gem 'task_scheduler', :git => 'git://github.com/mmell/task_scheduler.git'

Add the tables to your database:

rake task_scheduler:install:migrations
rake db:migrate

Add the route

In your Rails application, add a route

mount TaskScheduler::Engine => "/tasks"

then the url will be 0.0.0.0:3000/tasks/scheduled_tasks

Set a default host for urls in email messages in config/application.rb

config.action_mailer.default_url_options = { :host => "example.com" }

Add one or more ScheduledTasks

Visit the url where you have TaskScheduler::Engine mounted and create a Scheduled Task.

Create a shell script to trigger any waiting ScheduledTasks.

# /home/rails/cron_jobs/task_scheduler_cron.sh

#!/bin/bash
source /home/rails/.bash_profile # need to load rvm setup

cd /home/apps/main_app/production
/usr/bin/env rake RAILS_ENV=production task_scheduler:run

_Tip: It’s always a good idea to use full paths in scripts for cron._

Add a line to your crontab

1 * * * * /home/rails/cron_jobs/task_scheduler_cron.sh # run every hour

The controllers/task_scheduler/scheduled_tasks_controller expects there to be a layout named “admin”.

This project was originally available in the vendor/plugins of the Linksafe Ibroker on [Soureforge](linksafe.svn.sourceforge.net/viewvc/linksafe/rails/ibroker/trunk/vendor/plugins/at_linksafe_task_scheduler)

This project is released under the MIT-LICENSE.