Super Simplified CRON |
[eluser]BradEstey[/eluser]
I've tried two different methods of getting CRON to run CodeIgniter scripts today. They're the top two results on Google when you search "CRON Codeigniter" http://codeigniter.com/wiki/Category:Adv...ronScript/ http://jonathonhill.net/codeigniter/cron/ After getting a little frustrated with none of these solutions working on my server (don't ask me why hut: ) I came up with my own super simplified solution.. 1. Create your controller like normal. Mine is just simply cron.php, it contains a script that deletes all of the files in an ftp directory: Code: <?php 2. Create cron_model.php with the isCron() funtion. This function just checks to make sure the IP address is the IP of your server, to make sure that your cron script can't be accessed directly by users. If you have an array of possible Server IPs, then you would check them here.. if not then you might not need this model at all. Code: <?php 3. Create a file somewhere on your server called deleteftpfiles.php. I put it in a private folder below my root directory so that it can't be accessed directly. This file only needs one line of code: Code: <?php file_get_contents('http://www.yourdomain.com/cron/deleteftpfiles'); ?> 4. And finally, in crontab, I've opted to run it every Sunday at 12:00 AM: Code: 0 0 * * sun /usr/bin/php -q /var/www/vhosts/yourdomain/private/deleteftpfiles.php This probably isn't the most elegant solution.. but it works for me!
[eluser]loosetops[/eluser]
Check out this post http://ellislab.com/forums/viewthread/15...15/#742676 |
Welcome Guest, Not a member yet? Register Sign In |