Chef-client cookbook cron job



I need to setup a cookbook to be run daily at 1 am. I am trying to use chef-client cookbook, but no matter what setting I set, it runs about every 30 minutes.

I don;t want to set cron job manually as there are many nodes. I have separate role which is I am using as runlist. I did normal and override attributes from this role to set it up.

I tried to set hour/minute attributes along with use_cron_d to true/false. I tried to use init_style but it still runs every 30 minutes (± splay)

What I may be doing wrong…




I think I figures this…

I can’t use chef-client default recipe in my run_list, I have to use chef-client::cron instead.





Is there a way to specify timezone in chef-client cron?

I set a cron job to be run at midnight (verified it) and all my servers on UTC, but I see half severs (at least in chef server reports), ran at 5 am and other half at midnight…
Not sure what might cause this.




Was your recipe set to restart crond? And did the timezones on ther server get set to UTC, after crond started, the first time?

I often find it useful to reboot a server when changing the timezone, just to make sure I don’t have to pick and choose which daemons need to be restarted.



knife ssl fetch fails if I use the hostname in the knife.rb file.

I am able to ping telnet to port 443 and wget with the hostname .

[root@chefserver .chef]# knife ssl check
Connecting to host
ERROR: Service temporarily unavailable
stream_check': undefined methodclosed?’ for nil:NilClass (NoMethodError)
from /opt/chefdk/embedded/lib/ruby/2.4.0/net/http/response.rb:202:in
read_body' from /opt/chefdk/embedded/lib/ruby/2.4.0/net/http/response.rb:229:inbody’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:541:in
rescue in format_rest_error' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:538:informat_rest_error’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:510:in
humanize_http_exception' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:456:inhumanize_exception’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:447:in
rescue in run_with_pretty_exceptions' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:436:inrun_with_pretty_exceptions’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:220:in
run' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/ lib/chef/application/knife.rb:160:inrun’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/bin/knife:25:in
<top (required)>' from /opt/chefdk/bin/knife:250:inload’
from /opt/chefdk/bin/knife:250:in `’
[root@chefserver .chef]#

[root@chefserver ~]# hostname
[root@chefserver ~]# hostname -f
[root@chefserver ~]# cat /etc/hosts
# localhost localhost.localdomain localhost4
::1 localhost localhost.localdomain localhost6
localhost6.localdomain6 chefdk chefserver chef-compliance

[root@chefserver ~]# ping
PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=64
time=0.033 ms
64 bytes from ( icmp_seq=2 ttl=64
time=0.070 ms




I added environment_variable CRON_TZ=UTC but that didn’t help.

I am not sure when crond started. May be I will add that as first step in chef-client cookbook…