whenever/lib/tasks/whenever.rake

21 lines
511 B
Ruby
Raw Permalink Normal View History

2009-02-16 03:24:10 +00:00
namespace :whenever do
desc "outputs cron"
task :output_cron do
puts Whenever.cron(:file => "config/schedule.rb")
end
desc "writes cron"
task :write_cron do
require 'tempfile'
cron_output = Whenever.cron(:file => "config/schedule.rb")
tmp_cron_file = Tempfile.new('whenever_tmp_cron').path
File.open(tmp_cron_file, File::WRONLY | File::APPEND) do |file|
file << cron_output
end
sh "crontab #{tmp_cron_file}"
puts "[write] crontab file updated"
end
end