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
You can put a task (such as command or script) in a background by appending a & at the end of the command line. The & operator puts command in the background and free up your terminal. The command which runs in background is called a job. You can type other command while background command is running.
A background process is a computer process that runs behind the scenes (i.e., in the background) and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification.
The exit() function in PHP is an inbuilt function which is used to output a message and terminate the current script. The exit() function only terminates the execution of the script. The shutdown functions and object destructors will always be executed even if exit() function is called.
There is few things that you can do:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With