FAQ
I only need to run puppet weekly, so I made this little shell script and
put in the the /etc/cron.weekly folder, but it's not running. If I run the
script manually, it works just fine. Why not from cron?



#!/bin/bash

#################################
# Cron job managed by Puppet
#################################


# Randomize 15 minutes to avoid overloading server
sleep $((RANDOM % 900))
exec puppet agent --no-daemonize --onetime

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Ccx8LJ7QCRMJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Christopher Wood at Apr 19, 2012 at 7:55 pm
    Usually cron problems like this are because of the way cron shrinks your $PATH environment variable. Read "man 5 crontab" and "man 8 cron", or find them on the web. Or use the full path to your puppet executable.

    Why don't you have puppet set up the cron job for you? That way puppet will install its own cron job on the first (manual, setup) run and will work automatically thereafter. Plus if you want to change your run time later, you need only change your central manifest.

    cron { 'run puppet':
    command => "/usr/bin/puppet agent --no-daemonize --onetime",
    user => 'root',
    weekday => 2,
    hour => 1,
    minute => fqdn_rand(59),
    }


    On Thu, Apr 19, 2012 at 12:43:16PM -0700, thinkwell wrote:
    I only need to run puppet weekly, so I made this little shell script and
    put in the the /etc/cron.weekly folder, but it's not running. If I run the
    script manually, it works just fine. Why not from cron?

    #!/bin/bash

    #################################
    # Cron job managed by Puppet
    #################################

    # Randomize 15 minutes to avoid overloading server
    sleep $((RANDOM % 900))
    exec puppet agent --no-daemonize --onetime

    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To view this discussion on the web visit
    [1]https://groups.google.com/d/msg/puppet-users/-/Ccx8LJ7QCRMJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.

    References

    Visible links
    1. https://groups.google.com/d/msg/puppet-users/-/Ccx8LJ7QCRMJ
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Dave Burkholder at Apr 19, 2012 at 11:29 pm
    Well, I tried adding the full command path, and set the cron job to
    cron.hourly but that didn't work. :-(

    The reason I used a cron job (managed by Puppet as a file) was so that
    anacron would run the job on reboot if the system was down at 4:00 AM
    Sunday. I only need once-a-week running, but I do want to make sure each
    week gets its run, whether the machine was running or not.

    One thing I'm noticing is my apache2 logs. What does this activity
    represent?

    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:07:49 -0400] "PUT
    /production/report/system.sys1.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:09:25 -0400] "POST
    /production/catalog/weaverex.sys2.com HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:09:26 -0400] "PUT
    /production/report/weaverex.sys2.com HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:09:35 -0400] "POST
    /production/catalog/system.sys3.lan HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:09:36 -0400] "PUT
    /production/report/system.sys3.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:11:21 -0400] "POST
    /production/catalog/system.sys4.lan HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:11:22 -0400] "PUT
    /production/report/system.sys4.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:12:45 -0400] "POST
    /production/catalog/system.sys5.lan HTTP/1.1" 400 4476 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:12:46 -0400] "PUT
    /production/report/system.sys6.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:14:55 -0400] "POST
    /production/catalog/system.sys7.lan HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:14:56 -0400] "PUT
    /production/report/system.sys8.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:15:14 -0400] "POST
    /production/catalog/system.sys8.lan HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:15:15 -0400] "PUT
    /production/report/system.sys8.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:17:09 -0400] "POST
    /production/catalog/system.sys9.lan HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:17:10 -0400] "PUT
    /production/report/system.sys9.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:17:45 -0400] "POST
    /production/catalog/system.sys10.lan HTTP/1.1" 400 4476 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:17:46 -0400] "PUT
    /production/report/system.sys10.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:18:26 -0400] "POST
    /production/catalog/system.sys11.lan HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:18:27 -0400] "PUT
    /production/report/system.sys11.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:19:40 -0400] "POST
    /production/catalog/system.sys12.lan HTTP/1.1" 400 4492 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:19:41 -0400] "PUT
    /production/report/system.sys12.lan HTTP/1.1" 200 4220 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:19:44 -0400] "POST
    /production/catalog/system.sys13.lan HTTP/1.1" 400 4476 "-" "-"
    127.0.1.1:8140 <ip_address> - - [19/Apr/2012:19:19:45 -0400] "PUT
    /production/report/system.sys13.lan HTTP/1.1" 200 4220 "-" "-


    -----Original Message-----
    From: puppet-users@googlegroups.com
    On Behalf Of Christopher Wood
    Sent: Thursday, April 19, 2012 3:55 PM
    To: puppet-users@googlegroups.com
    Subject: Re: [Puppet Users] Cron job isn't running

    Usually cron problems like this are because of the way cron shrinks your
    $PATH environment variable. Read "man 5 crontab" and "man 8 cron", or find
    them on the web. Or use the full path to your puppet executable.

    Why don't you have puppet set up the cron job for you? That way puppet will
    install its own cron job on the first (manual, setup) run and will work
    automatically thereafter. Plus if you want to change your run time later,
    you need only change your central manifest.

    cron { 'run puppet':
    command => "/usr/bin/puppet agent --no-daemonize --onetime",
    user => 'root',
    weekday => 2,
    hour => 1,
    minute => fqdn_rand(59),
    }


    On Thu, Apr 19, 2012 at 12:43:16PM -0700, thinkwell wrote:
    I only need to run puppet weekly, so I made this little shell script and
    put in the the /etc/cron.weekly folder, but it's not running. If I run the
    script manually, it works just fine. Why not from cron?

    #!/bin/bash

    #################################
    # Cron job managed by Puppet
    #################################

    # Randomize 15 minutes to avoid overloading server
    sleep $((RANDOM % 900))
    exec puppet agent --no-daemonize --onetime

    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To view this discussion on the web visit
    [1]https://groups.google.com/d/msg/puppet-users/-/Ccx8LJ7QCRMJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.

    References

    Visible links
    1. https://groups.google.com/d/msg/puppet-users/-/Ccx8LJ7QCRMJ
    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Thinkwell at Apr 21, 2012 at 3:03 pm
    Ahah, I made a custom FACTER variable in my .bashrc file and that bash
    environment variable isn't run by cron. So that's my problem... I'll need
    to research how to pass a custom FACTER variable to a cron script and have
    it be accessible at script run time.



    On Thursday, April 19, 2012 3:43:16 PM UTC-4, thinkwell wrote:

    I only need to run puppet weekly, so I made this little shell script and
    put in the the /etc/cron.weekly folder, but it's not running. If I run the
    script manually, it works just fine. Why not from cron?



    #!/bin/bash

    #################################
    # Cron job managed by Puppet
    #################################


    # Randomize 15 minutes to avoid overloading server
    sleep $((RANDOM % 900))
    exec puppet agent --no-daemonize --onetime
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/pN4AXumKJeYJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Christopher Wood at Apr 21, 2012 at 4:52 pm
    What does the custom facter variable contain?
    On Sat, Apr 21, 2012 at 08:03:32AM -0700, thinkwell wrote:
    Ahah, I made a custom FACTER variable in my .bashrc file and that bash
    environment variable isn't run by cron.  So that's my problem... I'll need
    to research how to pass a custom FACTER variable to a cron script and have
    it be accessible at script run time.

    On Thursday, April 19, 2012 3:43:16 PM UTC-4, thinkwell wrote:

    I only need to run puppet weekly, so I made this little shell script and
    put in the the /etc/cron.weekly folder, but it's not running. If I run
    the script manually, it works just fine. Why not from cron?

    #!/bin/bash

    #################################
    # Cron job managed by Puppet
    #################################

    # Randomize 15 minutes to avoid overloading server
    sleep $((RANDOM % 900))
    exec puppet agent --no-daemonize --onetime

    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To view this discussion on the web visit
    [1]https://groups.google.com/d/msg/puppet-users/-/pN4AXumKJeYJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.

    References

    Visible links
    1. https://groups.google.com/d/msg/puppet-users/-/pN4AXumKJeYJ
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Dave Burkholder at Apr 21, 2012 at 4:56 pm
    It just contains the output of "hostname -i "
    On Apr 21, 2012 12:52 PM, "Christopher Wood" wrote:

    What does the custom facter variable contain?
    On Sat, Apr 21, 2012 at 08:03:32AM -0700, thinkwell wrote:
    Ahah, I made a custom FACTER variable in my .bashrc file and that bash
    environment variable isn't run by cron. So that's my problem... I'll need
    to research how to pass a custom FACTER variable to a cron script and have
    it be accessible at script run time.

    On Thursday, April 19, 2012 3:43:16 PM UTC-4, thinkwell wrote:

    I only need to run puppet weekly, so I made this little shell
    script and
    put in the the /etc/cron.weekly folder, but it's not running. If I run
    the script manually, it works just fine. Why not from cron?

    #!/bin/bash

    #################################
    # Cron job managed by Puppet
    #################################

    # Randomize 15 minutes to avoid overloading server
    sleep $((RANDOM % 900))
    exec puppet agent --no-daemonize --onetime

    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To view this discussion on the web visit
    [1]https://groups.google.com/d/msg/puppet-users/-/pN4AXumKJeYJ.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.

    References

    Visible links
    1. https://groups.google.com/d/msg/puppet-users/-/pN4AXumKJeYJ
    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Gabriel Filion at Apr 21, 2012 at 10:54 pm
    Hey, sorry to butt in for just a small comment:
    On 12-04-21 12:56 PM, Dave Burkholder wrote:
    It just contains the output of "hostname -i "
    In my understanding, this would probably be equivalent to the $ipaddress
    fact that comes with facter. Am I mistaken?
    On Apr 21, 2012 12:52 PM, "Christopher Wood" wrote:

    What does the custom facter variable contain?
    --
    Gabriel Filion

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Dave Burkholder at Apr 22, 2012 at 1:15 am
    No problem at all, Gabriel. These machines are running a firewall distro
    and have multiple NICs so that's why I need the custom facter for getting
    the correct IP.
    On Apr 21, 2012 6:54 PM, "Gabriel Filion" wrote:

    Hey, sorry to butt in for just a small comment:
    On 12-04-21 12:56 PM, Dave Burkholder wrote:
    It just contains the output of "hostname -i "
    In my understanding, this would probably be equivalent to the $ipaddress
    fact that comes with facter. Am I mistaken?
    On Apr 21, 2012 12:52 PM, "Christopher Wood" <christopher_wood@pobox.com
    wrote:

    What does the custom facter variable contain?
    --
    Gabriel Filion

    --
    You received this message because you are subscribed to the Google Groups
    "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to
    puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/puppet-users?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedApr 19, '12 at 7:43p
activeApr 22, '12 at 1:15a
posts8
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase