Cron job isn't running

100 views
Skip to first unread message

thinkwell

unread,
Apr 19, 2012, 3:43:16 PM4/19/12
to puppet...@googlegroups.com
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

Christopher Wood

unread,
Apr 19, 2012, 3:55:14 PM4/19/12
to puppet...@googlegroups.com
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),
}

> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@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

Dave Burkholder

unread,
Apr 19, 2012, 7:29:14 PM4/19/12
to puppet...@googlegroups.com
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 "-" "-

thinkwell

unread,
Apr 21, 2012, 11:03:32 AM4/21/12
to puppet...@googlegroups.com
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.

Christopher Wood

unread,
Apr 21, 2012, 12:52:13 PM4/21/12
to puppet...@googlegroups.com
What does the custom facter variable contain?

> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@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

Dave Burkholder

unread,
Apr 21, 2012, 12:56:27 PM4/21/12
to puppet...@googlegroups.com

It just contains the output of "hostname -i "

Gabriel Filion

unread,
Apr 21, 2012, 6:54:01 PM4/21/12
to puppet...@googlegroups.com
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" <christop...@pobox.com

> <mailto:christop...@pobox.com>> wrote:
>
> What does the custom facter variable contain?

--
Gabriel Filion

Dave Burkholder

unread,
Apr 21, 2012, 9:15:57 PM4/21/12
to puppet...@googlegroups.com

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.

Reply all
Reply to author
Forward
0 new messages