Forum Moderators: coopster

Message Too Old, No Replies

Mistake with PHP or CRON?

         

anand84

12:01 pm on Jun 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all

I had to set a CRON job to run every hour. However, I seemed to be having some problem with it. After a few discussions here at WebmasterWorld at [webmasterworld.com...] , I still seem to be having trouble.

I seem to be getting the following error:


/home/accountname/public_html/foldername/hourly_update.php: line 1:?php
: No such file or directory
/home/accountname/public_html/foldername/hourly_update.php: line 2: syntax error near unexpected token `'includes/application_top.php''
/home/accountname/public_html/foldername/hourly_update.php: line 2: ` require('includes/application_top.php');
'

Can someone see the mistake here?

Thanks
Anand

oziman

12:35 pm on Jun 12, 2007 (gmt 0)

10+ Year Member



Cron is attempting to run the script without calling the PHP interpreter on your system.

Try one of two things:

1. Put #!/path/to/php/interpreter as the first line above the part of the code that starts <?php

2. change cron so it runs the commands as /path/to/php /php/script/to/run

Ask your host what the full path is to php on the file system.

oziman

anand84

2:57 pm on Jun 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the help Oziman. I shall contact my website administrator and try it out.

Warm Regards

justgowithit

8:12 pm on Jun 12, 2007 (gmt 0)

10+ Year Member



change cron so it runs the commands as /path/to/php /php/script/to/run

If you're on shared hosting this should solve your problem. I just went through this issue the other day.

anand84

1:06 pm on Jun 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks a lot Oziman and JustGoWithIt

It seems to be running fine now. Though my cron update program is acheving the task desired, I still get this message:

<br />
<b>Notice</b>: Undefined index: DOCUMENT_ROOT in <b>/home/ACCOUNTNAME/public_html/includes/api.feedsprocessing.php</b> on line <b>193</b><br />
<pre>

I do not know if this is going to bother me, but does this mean anything?

Thanks

oziman

1:16 pm on Jun 13, 2007 (gmt 0)

10+ Year Member



I need to see the actual code on and around that line..

Glad to hear it works, though.

tomda

1:19 pm on Jun 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have define a variable DOCUMENT_ROOT, then you have presumably forgot the "$" sign => $DOCUMENT_ROOT

Anyway, the error message can be translated by
"Hey! What is this DOCUMENT_ROOT variable? I can't find it"

anand84

12:30 pm on Jun 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for your replies. It has not worked. I guess there is something else to this. I shall let you know if it works.

Thanks again..

jatar_k

12:40 pm on Jun 14, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I do not believe you can use DOCUMENT_ROOT in cron, or any other $_SERVER vars for that matter. Use explicit paths.

cron uses commands as you would use them from the command line

go to the command line and find the command/path to run your script. When you get the paths right then that is what you use for your cron