tags:

views:

929

answers:

3

I have found many questions and articles about this but i still have some difficulties. I'm using the following command /usr/bin/php home/domain.com/public_html/cron/script.php I receive the following error Status: 404 Not Found X-Powered-By: PHP/5.2.8 Content-type: text/html

No input file specified.

i'm using Cpanel, the file is hosted on domain.com/cron/script.php Anyideas, thanks :p

+2  A: 

Try:

wget http://domain.com/cron/script.php

and see if you get a better result.

lacqui
Mine may work, but you may want to look at chaos's better-reasoned answer.
lacqui
+7  A: 

Put a leading slash on the script name, i.e.

/usr/bin/php /home/domain.com/public_html/cron/script.php

Unless you actually intend to run the script through the web, as in lacqui's answer, and you don't mind random third parties being able to run it any time they like, there's no reason you should put it inside your public_html directory; quite the opposite.

chaos
Good point about not making the script public.
lacqui
I'll add here because it's probably not obvious to OP: by random third parties being able to run it 'any time they like', I also mean 'many times a second'. Since CPU-intensive and memory-intensive tasks are often candidates for cron jobs, you may be handing people an easy denial of service attack.
chaos
Only if you don't make sure it isn't already running first. Use your database to create a guard "CRON last started at " timestamp. Then in your cron don't run if the timestamp is X minutes/hours old.
jmucchiello
Cem Kalyoncu
+1  A: 

You might need to use the binary known as php-cli instead of just php.

X-Istence
That's for windows, in *nix you just use /usr/bin/php. And by the mention of cron its definitely *nix environment.
Cem Kalyoncu
@cemkalyoncu: Some systems ship a seperate php-cli that contains extra stuff like readline, and others. Can come in handy on the command line.
X-Istence