• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Task Scheduler

#1
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?
Reply

#2
What exactly are you looking for? There is already a way to run codeigniter commands using command the line.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply

#3
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
Reply

#4
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.
Practical CodeIgniter 3  • CodeIgniter 4 Foundations - Coming Soon • Vulcan - CLI Tools for CI4
Reply

#5
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.
Long live CodeIgniter!
Reply

#6
(05-19-2017, 09: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.
Practical CodeIgniter 3  • CodeIgniter 4 Foundations - Coming Soon • Vulcan - CLI Tools for CI4
Reply

#7
A suite of tools or ready-made commands would be handy. I can help on this one by the time a list is finalized.
Long live CodeIgniter!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.