Setting up overnight email script - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Setting up overnight email script (/showthread.php?tid=8694) |
Setting up overnight email script - El Forum - 05-27-2008 [eluser]acesfull9[/eluser] So I want to make a script that runs overnight and sends emails for my codeigniter application. I was wondering what is the best way to approach this while being able to take advantage of the code igniter libraries that may be useful. 1. I could write it as a controller and just request the url of that controller every night. With that, I am not sure about request timing out or someone accessing the controller who is not the overnight batch job. Is there anyway to call a codeigniter controller or some other class from the command line. Any suggestions of the best way to approach this would be greatly appreciated, thanks! Setting up overnight email script - El Forum - 05-27-2008 [eluser]James Gifford[/eluser] You can create a script which will call a CI controller from the crontab and run the code without using your webserver. Here is how I handle this: 1. Make a new folder in your application directory for storing CLI scripts. 2. Copy the index page in your web root to a new file in your scripts folder (we'll call it script.php). 3. Add a line like this at the top of script.php: Code: $_SERVER['PATH_INFO'] = '/controller_name/method_name'; Code: $system_folder = "/Library/WebServer/system"; Setting up overnight email script - El Forum - 05-27-2008 [eluser]acesfull9[/eluser] Thank you! |