I want to add 1 cron job in to the machine that will run every 5 minutes, for that I am using this manifest:
class cron_job{
file{"puppet_ls":
path => "/puppet/pls.sh",
ensure => present,
content => "#!/bin/sh\necho \"Hello World\"\nls -ltr /etc/puppet > /puppet/dump.txt"
}
file { "my_ls.cron":
path => "/etc/cron.d/my_ls.cron",
ensure => present,
owner => "root",
group => "root",
mode => 0644,
require => File["puppet_ls"],
content => "*/1 * * * * /puppet/pls.sh\n";
}
}
So this manifest do 2 things,
But I am not getting the file dump.txt inside /puppet/ Also if I runs, sh /puppet/pls.sh, it runs perfectly and generates the dump.
I am unable to understand where is the glitch.. :(
Please shed some light..
Thanks Ankur
You should use the cron
type that is built in to puppet.
file { '/puppet/pls.sh':
content => "#!/bin/sh\necho \"Hello World\"\nls -ltr /etc/puppet > /puppet/dump.txt",
mode => 0755,
}
cron { 'helloworld':
command => "/puppet/pls.sh",
user => root,
hour => '*',
minute => '*/5',
require => File['/puppet/pls.sh']
}
........
Crontab files placed in /etc/cron.d, or other cron. directories under /etc cannot have periods in their name.
This is a known bug: https://bugs.launchpad.net/ubuntu/+source/debianutils/+bug/38022
Removing the period from your filename (my_ls.cron) should resolve the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With