Puppet couldn t run a cron job

0 votes

I need to run a cron job every 5 mins, and to accomplish this I have a 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";
    }
}

This manifest creates a file /puupet/pls.sh with the content specific, that is actually running the command ls-ltr /etc/puppet and  * * * * /puppet/pls.sh\n, specifies to run it after every 1 minute.

But I am not getting the file dump.txt inside /puppet/  whereas if I run, sh /puppet/pls.sh, it runs successfully and generates the dump file.

What is the glitch here? Can Somebody help?

Aug 8, 2019 in Puppet by Karan
• 19,610 points
1,486 views

1 answer to this question.

0 votes

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']
}
answered Aug 8, 2019 by Sirajul
• 59,230 points

Related Questions In Puppet

0 votes
1 answer

Docker with Puppet: Run a conatiner using a native volume

When using the volumes array with docker::run, the command on ...READ MORE

answered Aug 16, 2019 in Puppet by Sirajul
• 59,230 points
1,300 views
0 votes
1 answer

Puppet in Docker: Can a docker container use Puppet only at Run-time?

Docker provides a solution to this problem ...READ MORE

answered Aug 19, 2019 in Puppet by Sirajul
• 59,230 points
769 views
+1 vote
1 answer

I am running a Jenkins job to sign the certificate by puppet master but it is failing

Refer to https://www.edureka.co/community/55971/puppet-error-while-signing-the-certificates This addresses a similar query like ...READ MORE

answered Mar 13, 2020 in Puppet by Liana
1,295 views
0 votes
0 answers
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,061 views
+2 votes
1 answer
0 votes
1 answer

Creating a cron job in puppet

Running a Puppet agent with cron can ...READ MORE

answered Jul 29, 2019 in Puppet by Sirajul
• 59,230 points
2,688 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP