From 8a84433a5f22cde20075b35bc9d71acbf512d638 Mon Sep 17 00:00:00 2001 From: Damien Date: Sat, 29 May 2010 20:38:15 +0800 Subject: [PATCH] Adding a short explanation about custom job type creation to the readme --- README.rdoc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.rdoc b/README.rdoc index 2cfa424..8dbf860 100644 --- a/README.rdoc +++ b/README.rdoc @@ -67,6 +67,30 @@ By mixing and matching the --load-file and --user opti If you want to override a variable (like your environment) at the time of deployment you can do so with the --set option: http://wiki.github.com/javan/whenever/setting-variables-on-the-fly +== Defining custom job types + +You can define custom job types in your schedule file: + + job_type :rails3_runner do |job| + job.command = "rails runner" + job.uses_bundler = true + end + + every 1.day, :at => "2am" do + rails3_runner "MyModel.do_something_amazing" + end + +This would create a job with the command "bundle exec rails runner". By defining jobs like this, you can also make reusable system commands such as: + + job_type :my_great_command do |job| + job.environment = false # this stops whenever appending '-e production' to the task + job.command = "/usr/bin/my_great_command" + end + + every 3.days do + my_great_command "arg1 arg2 arg3" + end + == Credit Whenever was created for use at Inkling (http://inklingmarkets.com) where I work. Their take on it: http://blog.inklingmarkets.com/2009/02/whenever-easy-way-to-do-cron-jobs-from.html