PHP asynchronous execution

Source: Internet
Author: User
PHP asynchronous execution problems when PHP executes the exec () method, it will wait until the exec method is fully executed before continuing to execute other code
While exec () will be executed for a long time, so that the page will remain in the waiting state,
Refresh after exec is executed,
So is there any way to make exec run in the background, so that the page does not have to be refreshed after exec is executed?


Reply to discussion (solution)

Add a command after the executed command &
However, not all commands used can be executed in the background.

Add a command after the executed command &
However, not all commands used can be executed in the background.

I tried it. no.
There is a button on the page,
1. click to update the database
2. page refresh after DB update
3. when the page is onload, use AJAX to execute a background method. this method is used to send an HTTP request to server 2.
4. when Server 2 receives a 3 request, execute the exec method. this method runs a bat file (which contains a Java jar package) under the Directory of server 2)

Because 4 runs for too long, a post is generated...

This does not seem to work. you can get an event queue on the server side. when Server 2 receives a 3 request, it adds an event and writes an event processing program on server 2.

You can see the benefits of event-based processing language ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.