Skip to content
Browse files

- Adding a basic recipe to verify that cron is running.

gned-off-by: Scott M. Likens <slikens@engineyard.com>
  • Loading branch information...
1 parent 3aad2ce commit a4deb3b410776a97e8a8151f464b6c0fb4bab94a Scott M. Likens committed Feb 22, 2011
View
13 cookbooks/cron_check/README.rdoc
@@ -0,0 +1,13 @@
+= DESCRIPTION:
+
+This cookbook will create a cron entry under the default user to touch /home/deploy/cron.timestamp.check. It additionally configures monit to verify that this file is accessable and recent, if it is not it will restart crontab.
+
+= USAGE:
+
+Step 1) Modify main/recipes/default.rb to require_recipe "cron_check"
+Step 2) Upload your new recipes to the environment (ey recipes upload -e <ENV>
+Step 3) Apply recipes
+
+= NOTES:
+
+If you'd like you can configure the monitrc to add an alert address so you can recieve email notification if there is ever a need to restart cron.
View
27 cookbooks/cron_check/recipes/default.rb
@@ -0,0 +1,27 @@
+# Recipe for testing cron is working properly.
+#
+cron "timestamp_check" do
+ user node[:owner_name]
+ minute "*"
+ hour "*"
+ day "*"
+ month "*"
+ weekday "*"
+ command "touch /home/#{node[:owner_name]}/cron.timestamp.check"
+ action :create
+end
+
+template "/etc/monit.d/cron_timestamps.monitrc" do
+ backup 0
+ source "cron_check.monitrc.erb"
+ owner "root"
+ group "root"
+ mode 0655
+ variables({
+ :owner => node[:owner_name]
+ })
+end
+
+execute "reload monit" do
+ command "monit reload"
+end
View
4 cookbooks/cron_check/templates/default/cron_check.monitrc.erb
@@ -0,0 +1,4 @@
+check file cron_timestamp_check with path /home/<%= @owner %>/cron.timestamp.check
+ start program = "/etc/init.d/vixie-cron restart"
+ stop program = "/etc/init.d/vixie-cron stop"
+ if timestamp > 16 minutes for 3 cycles then restart

0 comments on commit a4deb3b

Please sign in to comment.
Something went wrong with that request. Please try again.