![]() |
Run CI from cron - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Run CI from cron (/showthread.php?tid=15586) |
Run CI from cron - El Forum - 02-09-2009 [eluser]Tri Dang[/eluser] Hello everybody, For example, I have a Cron controller like: Code: class Cron extends Controller{ I can call methods of this controller from web browsers with no problem. But now I want to call it from cron jobs. Assume the path to root directory (which stores system folder) is /path. What do I put in cron to call my_method() (and load all CI stuff)? Thanks in advance. Run CI from cron - El Forum - 02-09-2009 [eluser]cwt137[/eluser] Why not use wget in your cron job? Code: wget http://localhost/cron/my_function Run CI from cron - El Forum - 02-09-2009 [eluser]Nick Husher[/eluser] That has the overhead of requiring everything to go through a net port. Check out MY URI on the CI wiki. It gives you straightforward access to a lot of CI functionality. Run CI from cron - El Forum - 02-09-2009 [eluser]cwt137[/eluser] Cool. Run CI from cron - El Forum - 02-09-2009 [eluser]eger[/eluser] That MY URI looks neat and simplifies a little bit of what I previously found. I had copied and modified the index.php to call a specific controller and method. I placed it in application/cli (though it could probably be somewhere more secure) and added PATH_INFO and absolute folder paths: Code: <?php Then I would add a cronjob for "/usr/bin/php -q /home/stats/public_html/stats/application/cli/logprocess.php". Run CI from cron - El Forum - 02-09-2009 [eluser]Tri Dang[/eluser] Thanks very much for all the replies! I check them now and let you know the result. Run CI from cron - El Forum - 02-11-2009 [eluser]Tri Dang[/eluser] Sorry replying late. I used MY_URI library from Nick Husher and it works great. Thanks again! |