Run PHP file with cron

This is the script to paste in cron to run a PHP file

php -f /home/username/public_html/cron-daily.php

Anyway I haven’t tried to put the script outside public_html directory. Logically PHP cannot run outside web root folder unless you set it to run outside web root folder in apache.

And you can use this script to run PHP by full URL. Even script on other server

lynx -dump http://yourdomain.com/yourscript.php >/dev/null 2>&1

Leave a Reply

Your email address will not be published. Required fields are marked *