Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:37:29+00:00 2026-05-26T22:37:29+00:00

Possible Duplicate: php execute a background process how can I achieve a task that

  • 0

Possible Duplicate:
php execute a background process
how can I achieve a task that should be done in thread in php

I have this PHP script that takes a little long to process. However I don’t want the viewer to wait for the script to finish. I want him to be able to continue browsing and/or close the browser. Yet I want the script to continue to work… How can I do this? Is there way to create some sort of thread that will allow such a thing?

p.s. I really don’t want to re-write the script in another language and execute it via os.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:37:30+00:00Added an answer on May 26, 2026 at 10:37 pm

    Avoid the idea of running paralell tasks (threads or processes) in PHP. It has some modules for this purpose, but they are not available on every platform and are not part of the PHP core, so the chances for you to be able to use them are very low.

    You have two options here:

    1. Split the long running task into several (cheaper) sub-tasks. Put them on a queue and make each request execute some of these sub-tasks (but don’t delay the output to the client too much).

    2. If you can’t split this big task, just setup a cron job for it. This way users are unnafected by the delay as the long running task is execute by the system.

      Another thing to note is that PHP script have (an overridable) time limit that halts execution after a given amount of seconds. Tasks that run via cron don’t suffer this limit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be
Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a
Possible Duplicate: PHP: Date larger than current date I have my dates in this
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved
Possible Duplicate: php date compare I have a date that I take from the
Possible Duplicate: php scandir --> search for files/directories I have a folder, inside this
Possible Duplicate: How can I execute a block of code exactly once in PHP?
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved
Possible Duplicate: PHP make if shorter I have an if statement that looks like
Possible Duplicate: PHP ToString() equivalent I get this error: Catchable fatal error: Object of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.