Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a php script in cron

Tags:

php

cron

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

like image 423
Omar Abid Avatar asked Nov 30 '22 12:11

Omar Abid


1 Answers

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.

like image 83
chaos Avatar answered Dec 03 '22 02:12

chaos