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,
- It makes a file /puupet/pls.sh with the content specifie, that is actually running the command ls-ltr /etc/puppet
- It makes an entry in the form of cron job for inside daily category and if you see the last line i.e * * * * /puppet/pls.sh\n, says that run after every 1 minute(for testing I kept one)
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