1

I have an apache server running a cakephp project.

There is this python code that I need to run which takes about 90min to 120 min to complete fully.

I need to invoke this script from python. I tried exec and passthru, nothing happens.

Also I need a way to find out when the python code is done so that my php code can go forward and continue some work.. How do I achieve this?

Chintan Shah
  • 935
  • 2
  • 9
  • 28
  • I suppose here is two ways: first - start python code as separated server (rpc, rest, whatever you want) or second - start this code via cron task. – Wizard Feb 24 '16 at 15:22
  • 1
    Possible duplicate of [PHP - Long Running Background Task](http://stackoverflow.com/questions/13802681/php-long-running-background-task) – floriank Feb 24 '16 at 15:34

1 Answers1

0

Did you try to search before asking? There are plenty of solutions and tutorials for that kind of task.

Your question is basically a duplicate of this one PHP - Long Running Background Task. So just see the answer there.

One option to background the task is to use fork. However, I strongly suggest using a proper job manager like gearman (see php extensions also), or queue, like amqp or zmq, to handle these tasks more cleanly. Which one is more suitable for your use case, I'll let you decide.

Community
  • 1
  • 1
floriank
  • 25,546
  • 9
  • 42
  • 66