Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running CakePHP Shells on Background

Tags:

shell

cakephp

Is it possible for CakePHP to execute a cakephp shell task on background for i.e running long reports. I would also want to update the current status back to the user via updating a table during the report generation and querying using Ajax.

like image 263
codegy Avatar asked Apr 13 '26 04:04

codegy


1 Answers

Yes, you can run shells in the background via normal system calls like

/path/to/cake/console/cake -app /path/to/app/ <shell> <task>

The tricky part is to start one asynchronously from PHP; the best option would be to put jobs in a queue and run the shell as a cron job every so often, which then processes the queue. You can then also update the status of the job in the queue and poll that information via AJAX.

like image 54
deceze Avatar answered Apr 18 '26 00:04

deceze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!