Cron job isn't running

閲覧: 100 回
最初の未読メッセージにスキップ

thinkwell

未読、
2012/04/19 15:43:162012/04/19
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

未読、
2012/04/19 15:55:142012/04/19
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

未読、
2012/04/19 19:29:142012/04/19
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

未読、
2012/04/21 11:03:322012/04/21
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

未読、
2012/04/21 12:52:132012/04/21
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

未読、
2012/04/21 12:56:272012/04/21
To: puppet...@googlegroups.com

It just contains the output of "hostname -i "

Gabriel Filion

未読、
2012/04/21 18:54:012012/04/21
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

未読、
2012/04/21 21:15:572012/04/21
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.

全員に返信
投稿者に返信
転送
新着メール 0 件