Pages

Monday, September 12, 2011

control cron from puppet

There is a nice way to control crontab from puppet. An example:


        cron { do_smt:
                command  => "/root/do_smt.sh",
                user     => root,
                hour     => 17,
                minute   => 30,
                monthday => '1-7',
                weekday  => 'Sat',
                month    => [1, 3, 5, 7, 9, 11],
        }

This would lead to a cron entry like this:

# HEADER: This file was autogenerated at Thu Sep 01 20:31:35 +0900 2011 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: do_smt
30 17 1-7 1,3,5,7,9,11 6 /root/do_smt.sh

For a complete reference to all the puppet cron type's attributes, check the puppet documentation site.

No comments:

Post a Comment