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

  • SEARCH
  • Home
  • 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 8052333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:31:05+00:00 2026-06-05T07:31:05+00:00

Let’s say I’ve createad a web scraping PHP page ( getdata.php ) that gets

  • 0

Let’s say I’ve createad a web scraping PHP page (getdata.php) that gets content of a specific website pages by cUrl, than saves some useful info to a txt file or database.

pseudo code of getdata.php,

min = get latest search id from database
max = 1.000.000 (yes one million different pages)

while (min < max) {

  url = "http://www.website.com/page.php?id=".$min
  content = getContentFromURL(url)
  saveUsefulInfoToDb(content)
  min++
  set latest search id as min in database
}

It’s OK, the proccess is,

  1. Open getdata.php on browser
  2. Wait
  3. Still wait, because there is about one million pages will be scraped.
  4. Wait
  5. And finally request time out.
  6. Fail

So the problem is I don’t know how can I make this proccess reasonable. opening page on a browser and waiting for it to finish scraping URLs, I think It’s a really bad practice.

How can I make getdata.php runnable in background like cron?

What is the best way to do it?

Thanks.

  • 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-06-05T07:31:06+00:00Added an answer on June 5, 2026 at 7:31 am

    use in the top of the code

    set_time_limit(0);
    ignore_user_abort(true);
    

    Then use a cron to fire it up each day or whenever it needs to. You definitely want this to be a background process and not a web page. Those two lines will allow it to run indefinitely as a web page or cmd line script. If you want to make it as a web page you can still use the cron to ‘fire’ it off with a line like

    0 0 * * * /usr/bin/curl "http://yoursite.com/getdata.php" >> "/var/www/errors.log"
    

    a bit of advice since I have done this many times: definitely make a logging function to print to a file so that you can see what it is doing as it runs or you will have no visibility and program into the php file a kill switch so you can tell it to stop running without having to use unix top or restart apache. It is probably a good idea to hard code in a kill time that it will stop if after a certain hour lest it run longer than a day and a second instance starts up and you have several running at once.

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

Sidebar

Related Questions

Let's say I'm writing a PHP (>= 5.0) class that's meant to be a
Let's say you have a method that expects a numerical value as an argument.
Let's say I have a bunch of links that share a click event: <a
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.
Let's say you have a class library project that has any number of supplemental
Let's say I want to write a function that validates an email address with
Let's say I have an abstract parent class called shape, and that there are
Let's say that I have a set of relations that looks like this: relations

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.