PDA

View Full Version : What am I doing wrong in PHP Cron Script?


hurrican
02-05-2005, 03:59 AM
Anyone know why when I try to call:
40 3 * * * root /usr/local/bin/php /home/forums/public_html/vb/delold.php

the cron script emails me an error of:



Date: Fri, 4 Feb 2005 03:40:00 -0600
From: Cron Daemon <root@localhost.localdomain>
To: root@localhost.localdomain
Subject: Cron <root@swish> /usr/local/bin/php /home/forums/public_html/vb/delold.php

Warning: main(./global.php): failed to open stream: No such file or directory in /home/forums/public_html/vb/delold.php on line 3

Fatal error: main(): Failed opening required './global.php' (include_path='.:/usr/local/lib/php') in /home/forums/public_html/vb/delold.php on line 3



I think my problem is not having the cron setup correctly.. This is a dedicated server in which I run myself with no other websites, so I have full root access.. Any suggestions?

trafix
02-05-2005, 04:06 AM
just use the direct relative path from the cron folder

../../delold.php

hurrican
02-05-2005, 01:21 PM
Thanks trafix,
however, that did not work, I still receive the same message. The PHP file requires global.php, and global.php requires ./admin/functions.php I believe that is where my problem is stemming from. if I run it from anywhere other than crontab, it works fine, but as soon as I edit it to run in crontab, I receive that error message. I'm wondering if I need to create a cron.sh command and make it change directory into my fourms path?

trafix
02-05-2005, 07:39 PM
yep ok i have also found that the cron folder lacks some function.

I have had to do some cron jobs like this ....

1) the cron script only has code to

require_once('../whatever.php');


2) then code your script and call it whatever.php and stick it in the includes folder ;)