Cron task not working created by puppet

I want to add 1 cron job to a machine that will run every 5 minutes, because I use 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 manifesto does 2 things

  • It creates a file /puupet/pls.sh with content content, which actually executes the ls-ltr / etc / puppet command
  • It writes in the form of a cron job for the daily category, and if you see the last line, that is * * * * / puppet / pls.sh \ n , it says that it starts after every 1 minute (for testing, I saved one)

But I don’t get the dump.txt file inside / puppet / Also, if I run sh / puppet / pls.sh , it works fine and generates a dump.

I can’t understand where the glitch is .. :(

.

+4
2

cron , .

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']
}
........
+7

Crontab, /etc/cron.d, cron. /etc .

: https://bugs.launchpad.net/ubuntu/+source/debianutils/+bug/38022

(my_ls.cron) .

+3

Source: https://habr.com/ru/post/1532776/


All Articles