How to run php file using cron jobs


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.example.com/cron.php?id=someHashCode


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)
Share on Google Plus

About srimaster

Tech Dropper is simple, easy and newest technology source with experiments and demos. I will give you tutorials, notes, code snippets, demos using PHP, MySQL, jQuery, HTML, CSS, Ajax and Javascripts.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment