Having problems running a cron job.

3 posts / 0 new
Last post
#1 Sat, 09/12/2009 - 11:39
Anonymous

Having problems running a cron job.

Hi there,

I have a problem trying to get my cron job working.

The script runs fine when I run it from my browser, it does everything it shoul, no errors.

I have set it up as a cron job and I am running it with the Run Now button but I get a file error:

Output from command php -q /home/focus7/public_html/auto_support.php ..

PHP Warning: require_once(/lib/swift_required.php): failed to open stream: No such file or directory in /home/focus7/public_html/auto_support.php on line 9

Warning: require_once(/lib/swift_required.php): failed to open stream: No such file or directory in /home/focus7/public_html/auto_support.php on line 9 PHP Fatal error: require_once(): Failed opening required '/lib/swift_required.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/focus7/public_html/auto_support.php on line 9

Fatal error: require_once(): Failed opening required '/lib/swift_required.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/focus7/public_html/auto_support.php on line 9

<- Return to cron job | Return to cron list

The actual line it is failing on is the second one of these two:

$swift_path = $_SERVER['DOCUMENT_ROOT']."/lib/swift_required.php"; require_once("$swift_path");

I use the path because in other scripts I call the library from different directories.

So, I assume that the cron job does not like the $_SERVER['DOCUMENT_ROOT']. bit ?

How should I address the swift script to make cron happy ?

Can I do it in a way that will work from the browser as well ?

( I can hard code the path, it doesn't need to have the "doc_root" bit in it for this particular script.)

Thanks for some guidance. ,

Sat, 09/12/2009 - 11:51
andreychek

Well, "$_SERVER['DOCUMENT_ROOT']" is a variable that's set by Apache.

So if you're running it from Cron, rather than serving it from a website, that variable will be empty.

To fix that, you'd just have to explicitly set the path rather than relying on that variable.

-Eric

Sun, 09/13/2009 - 10:41
Davvit

Thanks for the help, it is working nicely now :)

Topic locked