{"id":147,"date":"2013-01-10T21:21:26","date_gmt":"2013-01-10T21:21:26","guid":{"rendered":"http:\/\/www.nicovs.be\/?p=147"},"modified":"2013-01-11T21:34:40","modified_gmt":"2013-01-11T21:34:40","slug":"puppet-creating-cronjobs-via-a-manifest","status":"publish","type":"post","link":"https:\/\/www.nicovs.be\/?p=147","title":{"rendered":"Puppet: Creating Cronjobs via a manifest"},"content":{"rendered":"<p>Creating cron jobs via Puppet is fairly easy and well explained in available docs. However, I had some trouble adding cron jobs that needed to run at 2 different times a day.<\/p>\n<p>Normal cron behavior is that you just enter a , in between your 2 timestamps and everything is done.<\/p>\n<p>Eg something like this:<\/p>\n<pre class=\"lang:default decode:true\">0 23,5 * * * \/usr\/bin\/php5 \/home\/nicovs\/update_cron.php<\/pre>\n<p>Now, when creating a cronjob with Puppet, you&#8217;d think that you can just type<\/p>\n<pre class=\"lang:default decode:true\">hour  => \"23,5\",<\/pre>\n<p>in your manifest. The answer is: nope!<\/p>\n<p>This is the error you&#8217;ll get:<\/p>\n<pre class=\"lang:default decode:true\">err: Failed to apply catalog: Parameter hour failed: 23,5 is not a valid hour at \/etc\/puppet\/manifests\/nodes.pp:5<\/pre>\n<p>In the example below you&#8217;ll see that you have to use array&#8217;s to define your cron schedule:<\/p>\n<pre class=\"lang:default decode:true\">cron { 'update_cron':\r\n    ensure  => 'present',\r\n    command => '\/usr\/bin\/php5 \/home\/nicovs\/update_cron.php',\r\n    user => 'nicovs', \r\n    hour => [ 23, 5 ], \r\n    minute => '30', \r\n}<\/pre>\n<p>If you want to schedule this command to run every hour, your can use this however:<\/p>\n<pre>hour  => \"*\/1\",<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Creating cron jobs via Puppet is fairly easy and well explained in available docs. However, I had some trouble adding cron jobs that needed to run at 2 different times a day. Normal cron behavior is that you just enter a , in between your 2 timestamps and everything is done. Eg something like this: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18],"tags":[],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-puppet"],"_links":{"self":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=147"}],"version-history":[{"count":4,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}