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 8277919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:50:03+00:00 2026-06-08T08:50:03+00:00

I have an application written in PHP (Not website, an application), that has an

  • 0

I have an application written in PHP (Not website, an application), that has an infinite loop for its logic until the application shuts down. One issue with it that I’ve noticed is I get incredibly high CPU usage (Obviously), and I’ve tried using C++ methods I’ve done in the past to lower the CPU usage. Not many of them seem to work.

I’ve tried:

sleep(1);

and:

time_sleep_until(microtime(true)+0.2);

But neither seem to lower utilization.

Any tips?

  • 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-08T08:50:05+00:00Added an answer on June 8, 2026 at 8:50 am

    You can configure execution of your jobs when they are needed to be executed. So if this infinite script needs to do/check something every minute you can just do it when there is a change otherwise sleep.

    Your problem can be on something else your script does other than itself. Here is an example hope it helps.

        set_time_limit(0);
        ignore_user_abort(true);
        $minutes = NULL;
    
        do {
            try {
                // Run jobs, only when the minute has changed
                $now = getdate();
                if ($now['minutes'] != $minutes) {
                    $minutes = $now['minutes'];
                }       
            }
            catch (Exception $e) {
                // Catch here and handle
            }
            sleep(10);
        } while (TRUE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small AJAX application, written in PHP that I did not secure
I have an application written in PHP that uses a COM dll written in
I have written a PHP application that uses Objects heavily. Added, deleting, updating etc..
I have a web application, written in PHP that incorporates Javascript and JQuery, that
We have a web application written in PHP that exports MySQL query results to
I have a PHP application that is written with Zend Framework. It uses Phing
I have a small application written in PHP and a mysql database hosted on
I'm working on a web application written on php. I have some objects (represented
I have a custom built application framework written in PHP which I have been
I have written a PHP application which requires storage of millions of integers between

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.