[SOLVED] How do I create a cron job via a chef receipe using the cron resource?

Issue

This Content is from Stack Overflow. Question asked by runningraptor

I have the following in the cron.rb file.

cookbook 'cron', '~> 7.0.4', :supermarket

cron 'Check-In to Chef Manage' do
   minute '*/2'
   command 'chef-client'
 end

I’ve verified that the recipe is on the node, via Chef Manage, and yet it doesn’t run on the node.

I don’t understand if anything else needs to be configured.



Solution

The first line is not needed. Leaving the recipe (i.e. cron.rb) as:

cron 'Check-In to Chef Manage' do
   minute '*/2'
   command 'chef-client'
 end

Second, cron.rb must be called in the default.rb file; i.e. include_recipe "<cookbook nam>::cron"


This Question was asked in StackOverflow by runningraptor and Answered by runningraptor It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?