CodeIgniter Forums

Full Version: Task Scheduler
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm looking for a way to setup 1 cron job on the server and let the framework do the rest.

There are some libraries on GitHub that try to achieve this, but they don't work perfectly with CodeIgniter.
https://github.com/lavary/crunz
https://github.com/jobbyphp/jobby

I also found out that Laravel has such a task scheduler...
https://laravel.com/docs/5.4/scheduling

Are there any plans or is there enough interest in such a feature?
What exactly are you looking for? There is already a way to run codeigniter commands using command the line.
In CI, you can use the is_cli() function in your controller (to prevent web access) and add a cron job to your index.php file with, as argument, your controller and method.

Sample: cron_controller.php, method executeJobs
* * * * * * php /path/to/index.php cron executeJobs
I imagine what he's looking for is to have the cronjob setup to hit one specific file on the application every minute or 5 minutes, or whatever. Then, the task scheduler is responsible for running the appropriate jobs at the appropriate interval. That way it's all managed within the application and is simple to change and keep consistent between environments since you can commit it to version control, and not have to change the cronjob itself.

I do think this is something that would be quite handy, and I've done several variations on this in the past in my own projects, including the one that is with Sprint, though I'm not 100% happy with that one, honestly. It's been talked about and is one of my "wishlist items" that I think might show up in CI at some point, but not for the initial release of v4.
Before moving in with Scheduler, better enhance CI4's CLI and make it similar to Laravel's shell based feature Artisan Console https://laravel.com/docs/5.4/artisan#introduction.
(05-19-2017, 08:14 PM)prezire Wrote: [ -> ]Before moving in with Scheduler, better enhance CI4's CLI and make it similar to Laravel's shell based feature Artisan Console https://laravel.com/docs/5.4/artisan#introduction.

CI4 has a fair amount of that built-in already. And has a CLI library to assist making commands. And to test them out, I've started a suite of code generation tools. Though that definitely has farther to go and probably won't see much more happen on it until after the Alpha/Beta release.
A suite of tools or ready-made commands would be handy. I can help on this one by the time a list is finalized.