[LRUG] Disrespectful cron
Dominic Mitchell
dom at happygiraffe.net
Tue Feb 13 08:41:44 PST 2007
On Tue, Feb 13, 2007 at 04:06:01PM +0000, Andrew Stewart wrote:
> Hi Everyone,
>
> I'm trying to set up cron on a server so that I can clear out old
> sessions, rotate log files, etc. I've used cron lots of times before
> but for some reason can't get it working now. Is anyone out there
> good at this sort of thing?
>
> I've simplified what I'm trying to do as far as I can but am still
> stuck. Here it is:
>
> I have a Ruby script at /home/deploy/cron_test.rb:
>
> #!/usr/bin/ruby
> puts 'Hello'
>
> Its permissions are 777. Running 'which ruby' gives /usr/bin/ruby.
>
> crontab -l gives:
>
> 35 * * * * /usr/bin/ruby /home/deploy/
> cron_test.rb > /home/deploy/cron.log
If that's a log file, you probably want to say:
/usr/bin/ruby /home/deploy/cron_test.rb >> /home/deploy/cron.log
Otherwise each run will wipe out the previous file.
> (I update the minutes field every time I try to test cron.)
>
> Now I would expect cron to fire at 35min past any hour and write
> 'Hello' to the file /home/deploy/cron.log. But nothing is written to
> that file. In fact the file is not created at all. Creating it
> myself and giving it 777 permissions doesn't help either.
>
> So as far as I can tell cron is not executing my crontab. cron
> itself is running as proved by ps aux | grep cron:
>
> root 32229 0.0 0.3 2480 960 ? Ss 08:37 0:00 crond
> deploy 950 0.0 0.1 1672 448 pts/0 R+ 11:04 0:00 grep cron
>
> Does anyone have any ideas?
There's normally a log in /var/log/cron.log saying what cron is
attempting to do. Have a look in there.
Another thing to try is inserting a line in your crontab like this one
so you get mailed any output.
MAILTO=me at some.where
One last tip -- get rid of any blank lines in the crontab. They've
caused me trouble in the past.
-Dom
More information about the Chat
mailing list