summaryrefslogtreecommitdiff
path: root/lib/chef/provider/cron.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider/cron.rb')
-rw-r--r--lib/chef/provider/cron.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index 87452b4872..e80f70d8bb 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -29,6 +29,7 @@ class Chef
ENV_PATTERN = /\A(\S+)=(\S*)/
CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :command, :mailto, :path, :shell, :home, :environment]
+ WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday]
def initialize(new_resource, run_context)
super(new_resource, run_context)
@@ -220,9 +221,18 @@ class Chef
@new_resource.environment.each do |name, value|
newcron << "#{name}=#{value}\n"
end
- newcron << "#{@new_resource.minute} #{@new_resource.hour} #{@new_resource.day} #{@new_resource.month} #{@new_resource.weekday} #{@new_resource.command}\n"
+ newcron << "#{@new_resource.minute} #{@new_resource.hour} #{@new_resource.day} #{@new_resource.month} #{weekday_in_crontab} #{@new_resource.command}\n"
newcron
end
+
+ def weekday_in_crontab
+ weekday_in_crontab = WEEKDAY_SYMBOLS.index(@new_resource.weekday)
+ if weekday_in_crontab.nil?
+ @new_resource.weekday
+ else
+ weekday_in_crontab.to_s
+ end
+ end
end
end
end