Gilbert Kakaz
Gilbert Kakaz

Reputation: 1567

running processes in background php

I have few cronjob that summarize data and validate data for my site. Some of them have processes that needs to be run in background.

Example:

cronjob1.php execute cronjob2.php using exec

This cronjob2.php runs another cronjob3.php using exec and cronjob3 needs to be completed then cronjob2 and then cronjob finish.

I currently have an issue where the cronjob1.php takes 2 hours to finish.

is there a better way to run this so it run faster?

Thank You

Upvotes: 10

Views: 322

Answers (2)

Sonal Khunt
Sonal Khunt

Reputation: 1894

if cronjob1 have many database operation than create store procedures for that and make indexing on most use table fields

this increase your cronjob performance....

Upvotes: 0

RageZ
RageZ

Reputation: 27323

There is few things that you can do:

  • make sure that your script use permanent connection, this way you won't loose time connecting and disconnecting from the database server.
  • implement a logging mechanism, so you can identify which part of the script run slowly, logging the time spent on each database queries would be a good idea
  • try to optimize your database as much as possible, you should use explain on slow queries and create the needed indexes.

Upvotes: 18

Related Questions