A cron question


#1

Hello.
I have a problem with cron jobs.
I have a script to check for news on RSS Feeds and if any new, to add to cache files.
When i go to cron file with browser, everything works fine.
But when cron is running, i am receive many errors, like “is not writeable”, “file_put_contents” etc.
What can i do?Thanks


#2

It’s possible that it’s a relative path issue. What’s your entire crontab entry?

-Scott


#3

This is my cron:
/dh/cgi-system/php5.cgi /home/me/site.com/cron.php


#4

Interesting. I always use /usr/local/php5/bin/php
It’s not the exact same as the one in /dh/, but probably close enough.

Where did you create this cronjob? In the panel, or in the shell? And under which user? The same user as the home directory?

Can you post the contents of cron.php? Since it’s in your site directory, it probably doesn’t contain any sensitive information.

-Scott


#5

Another possible way to run cron.php is to programmatically access it via HTTP using curl. This way cron.php will run in exactly the same environment as when you load it in a browser, so there is less room for problems:

curl -sS http://site.com/cron.php

Add “> /dev/null” if you don’t want have the output of cron.php emailed to you.


#6

Great idea! That’s my lazy man’s way that some packages actually recommend. The rest of the time, I need to pass some arguments, so I have to call it from the actual PHP binary.

-Scott


#7

sdayman, i will try your entry.
I made it from Cron’s panel.

My cron.php uses RSS script to grab the feeds from various sites and add the newest items to database.
However, it creates zip files, and/or read/write cache and these are my problems.

habilis i will try your entry too. I set the cron to run every hour, so i can tell you if any of these works.