403 forbidden error from cron

Posted by user112570 on Server Fault See other posts from Server Fault or by user112570
Published on 2012-04-08T23:08:28Z Indexed on 2012/04/08 23:32 UTC
Read the original article Hit count: 278

Filed under:

I have some php code that runs fine in a browser but now I want to use the same code and execute it from a cron script I'm getting issues.

i tried the command on cron wget -O /dev/null http://www.mydomain.com/test.php but if i try that in the terminal i get the error below.

What is the correct command to run a php file from cron? and do I need to add extra line of code to the top of my php file?

The problem I'm getting is

-bash-3.2$ wget -O /dev/null http://www.mydomain.com/test.php
--2012-04-08 15:59:41--  http://www.mydomain.com/test.php
Resolving www.mydomain.com... 46.***.***.1
Connecting to www.mydomain.com|46.***.***.1|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2012-04-08 15:59:41 ERROR 403: Forbidden.

I gave the file 755 permissions and even 777 permissions, but can't see what I'm doing wrong.

© Server Fault or respective owner

Related posts about cron