I'm trying to schedule my Controller Method in PHP CodeIgniter; I mean I need to call a controller method on specified times!My server is a Windows Server!
So far I followed the following article (http://amitdhamu.com/blog/automating-php-using-task-scheduler/) which schedules a PHP file (calls whole of the PHP File, but I need to call just a controller method!); then I researched and someone at "Scheduling a controller method by Windows task scheduller" said I can do it by:
php C:\Apache\htdocs\index.php myController <myMethod> <arg1> <arg2>
sample:
php C:\Apache\htdocs\index.php users update
I guess he meant something like :
php C:\xampp\htdocs\Project1\application\controllers\site.php test
Which test method is inside my "site" controller! But this one did not work either!
Could you please how I use schedulig to call a controller method on specified times for a Windows Server?
Thanks
I don't have any experience doing this, but Googling I managed to pull this together:
schtasks /create /tn "Test Cron Job" /tr "C:\PHP5\php.exe -f C:\xampp\htdocs\Project1\application\controllers\site.php" /sc hourly
This will run hourly. I don't think you can specify a specific method, though you can add specific command line arguments.
Sources: http://php.net/manual/en/install.windows.commandline.php and http://drupal.org/node/31506
You can download curl(http://curl.haxx.se/) command line util and write a bat file to call your url where the controller method is executed then schedule the bat file in windows.
http://curl.haxx.se/docs/httpscripting.html
This is one of the be easiest way to achieve this.