Linux PHP Cron Job

Exos

VIP Member
VIP Member
Joined
Sep 28, 2010
Messages
5,280
Reaction score
3,137
Location
Rat's Bedroom
Trying to run a php script in a command shell on Debian 6.0 (Turnkey)

Works fine on a terminal session but I'm trying to set it up as a cron job and doesn't want to play ball.

Tried

php /home/update_scripts/update.php

/usr/bin/php5 /home/update_scripts/update.php

each time I get no such file or directory in /home/update_scripts/config.php on line 3

No joy, what am I doing wrong?

This is the config.php

?php

require("../../www/config.php");

?>
 
Last edited:
Where are you running it within the terminal?

Include the full path to your config require("/mydirectory/path/www/config.php");
 
Where are you running it within the terminal?

Include the full path to your config require("/mydirectory/path/www/config.php");

From a putty session and that works fine, but the cron job doesnt

tried the full path but then I get another message similar as that references another point.

It's not so much of an issue now to be honest as I only need to run it once to backfill some data.
 
Remember that cron doesn't inherit the .profile when you're running it. So you need to source all your environmental variables within your script.
 
I just realized my post might be fairly cryptic and geeky. If you write a wrapper script that at the very top does a:

./users/<login_name>/.profile or .bash_profile
php /home/update_scripts/update.php
 
Back
Top