[Techtalk] A PHP script in a crontab.

Kathryn Andersen kat_lists at katspace.com
Sat Jan 29 20:12:11 EST 2005


On Fri, Jan 28, 2005 at 11:47:17PM +1100, Sue Stones wrote:
> I have written a PHP script that I want to be executed automatically by 
> using cron.  But the problem is that nothing happens when I run it that 
> way.
> 
> The script runs in a web browser, and works as I want it to, but when I 
> put it in a cron tab, nothing happens.  I can think of 2 possible causes 
> of error.  (1) I am calling it wrong, I have been told by the web hoster 
> that the call statement should be something like this:
> 
> "GET http://www.hostyorkshire.com/scgi-bin/script.php > /dev/null "

Okay, given that we've established that "GET" is a sort of
mini-web-server (which is why you pass it the URL of your script),
I wonder if it would work if you called GET with the full pathname of
GET (if your web-hoster would tell you what it is).

The reason I say this is that 90% of the time when a cron job doesn't
work (and it works when the user runs it himself) is because the
environment of cron is very minimal, and not the same as that of the
user.  This causes problems in two ways:

1) cron can't find the command it's supposed to run, because the PATH
environment variable is different
2) cron runs the command, but the command is expecting certain
environment variables to be set, and they aren't.

Mary's suggestion of writing a simple sample script is a good idea,
because it may help to establish whether problem (1) or problem (2) is
the one causing the failure, or if it is something else.
 
Kathryn Andersen
-=-=-=-=-=-=-=-=-
It is not good for a man to be without knowledge,
and he who makes haste with his feet misses his way.
		-- Proverbs 19:2
-- 
 _--_|\     | Kathryn Andersen	<http://www.katspace.com>
/      \    | 
\_.--.*/    | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
      v     | 
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha!  |	-> Earth -> Sol -> Milky Way Galaxy -> Universe


More information about the Techtalk mailing list