Skip to content

Commit

Permalink
Updated cronjob to support day and month. If no values are set they w…
Browse files Browse the repository at this point in the history
…ill default to *.
  • Loading branch information
onema committed Oct 31, 2013
1 parent 53757ce commit ea27e7b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,37 @@ Default will create multiple cronjobs based on the following configuration value
"staging_site": {
"cron_jobs": [
{
"name": "send_email",
"hour": "1",
// Send an email every sunday at 8:10
"name": "send_email_sunday_8",
"minute": "10",
"hour": "8",
"weekday": "6",
"command": "cd /srv/www/staging_site/current && php .lib/mailing.php"
},
{
"name": "process_jobs",
"hour": "3",
"minute": "15",
"weekday": "3",
// Run at 8:00 PM every weekday Monday through Friday ONLY in November.
Notice there is no day
"name": "run_at_20h_nov",
"minute": "0",
"hour": "20",
"month": "10",
"weekday": "1-5",
"command": "cd /srv/www/staging_site/current && php app/console command:start:jobs"
}
]
},
"production_site": {
"cron_jobs": [
{
"name": "do_something_fun",
"hour": "1",
"minute": "10",
"weekday": "6",
// Run Every 12 Hours - 1AM and 1PM
"name": "run_every_12h",
"hour": "1-13",
"command": "cd /srv/www/production_site/current && php app/console hello:world"
},
{
"name": "do_something_stupid",
"hour": "3",
// Run every 15 minutes
"name": "do_something_stupid_every_15m",
"minute": "15",
"weekday": "3",
"command": "cd /srv/www/production_site/current && php app/console memory:leak"
},
]
Expand Down
1 change: 0 additions & 1 deletion composer/recipes/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
code <<-EOH
curl -s https://getcomposer.org/installer | php
php composer.phar install -n --optimize-autoloader --prefer-source
#php composer.phar update
EOH
end
end
16 changes: 12 additions & 4 deletions cronjobs/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
node[:deploy].each do |application, deploy|

node[:custom_env][application.to_s][:cron_jobs].each do |cron_values|
minute = cron_values[:minute] rescue '*'
hour = cron_values[:hour] rescue '*'
day = cron_values[:day] rescue '*'
month = cron_values[:month] rescue '*'
weekday= cron_values[:weekday] rescue '*'

cron "#{cron_values[:name]}" do
hour "#{cron_values[:hour]}"
minute "#{cron_values[:minute]}"
weekday "#{cron_values[:weekday]}"
command "#{cron_values[:command]}"
minute "#{minute}"
hour "#{hour}"
day "#{day}"
month "#{month}"
weekday "#{weekday}"
command "#{command}"
end
end
end

0 comments on commit ea27e7b

Please sign in to comment.