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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:07:06+00:00 2026-05-21T18:07:06+00:00

I have some long-running CLI PHP scripts that run regularly via cron. I’d like

  • 0

I have some long-running CLI PHP scripts that run regularly via cron. I’d like them to complete as quickly as possible but without seriously impacting other processes (such as web server responsiveness).

Currently I am running the script with

nice -n 19

and also have experimented with inserting very short usleep() calls, such as 50 microseconds in my main loop. Still this isn’t always yielding as quickly as I’d like on a single-core VM. BTW, I’m not saturating RAM so there’s no paging happening.

I’ve read that usleep() is a system call that will allow the scheduler to assign priority to other processes if needed more quickly than if I didn’t have any system calls.

What I’m wondering is if there’s a better method of doing this in PHP. Such as a call that doesn’t sleep but yields priority right away.

Also, I know other languages are more efficient than PHP, but this is part of a bigger app written in Symfony+Doctrine. I don’t want to split into multiple languages and lose the business logic benefits of the app’s models.

  • 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-21T18:07:06+00:00Added an answer on May 21, 2026 at 6:07 pm

    If nice isn’t cutting it for you, consider picking a different scheduler for your kernel. This is a problem with your OS prioritizing processes. It isn’t something that you can readily solve inside your application (whether it’s written in PHP or any other language).

    Oh and remember, nice levels don’t really kick in unless you’re starving for CPU cycles. If your CPU is mostly idle, even a process with a nice level of 19 is allowed to eat all the CPU cycles it wants.

    Edit: In fact, make sure you’re CPU-bound before going down this path. If you’re I/O bound then CPU prioritisation isn’t going to have much of an effect.

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

Sidebar

Related Questions

I have some (potentially) long-running ajax calls that I would like to abort if
I have some long running scripts with breaks requiring input/interaction to continue but when
I have some long-running operations that number in the hundreds. At the moment they
I would like to have some long-running server applications periodically output general GC performance
I have a class that has some long running methods, in which they do
I have some queries that run for a quite long (20-30 minutes). If a
I have a collection of PHP scripts that are extremely CPU intensive, juggling millions
I occasionally have some long running AJAX requests in my Wicket application. When this
We have a long running data transfer process that is just an asp.net page
I have a long-running console-based application Sender that sends simple text to STDOUT using

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.