how to run php file using cron jobs

cron, php

Solution

Cron runs commands as they would be ran via the shell, so running PHP would use local paths.

You need to use a command like:

`php /home/USER/public_html/cron.php`

Or if including the query string is necessary, use cURL instead (if it's installed):

`curl http://www.wetube.org/cron.php?id=01001`

You might want to look at not exposing your cron scripts to the internet - move them to outside your web directory because if someone finds it they can constantly reload it to spam your cron scripts (i.e. sending lots of emails)

Problem

I have a E-mail schedule runs everyday on php page using cron jobs. The php code workds fine when i run the page using a link. Now when I run the php script using cron jobs, it also works fine but when I put some query the cron jobs won't understand the link. for example: `http://www.wetube.org/cron.php?id=01001` so now if I try to run this everyday using cron job it's doesn't work. But if we just erase the query it works fine. Do you guys know any code which makes this link work in cron job?

Original source