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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:11:33+00:00 2026-05-14T20:11:33+00:00

I have a daily cron job that grabs 10 users at a time and

  • 0

I have a daily cron job that grabs 10 users at a time and does a bunch of stuff with them. There are 1000’s of users that are part of that process every day. I don’t want the cron jobs to overlap as they are heavy on server load. They call stuff from various APIs so I have timeouts and slow data fetching to contend with.

I’ve tried using a flag to mark a cron job as running, but it’s not reliable enough as some PHP scripts may time out or fail in various ways.

Is there a good way to stop a cron job from calling the PHP script multiple times, or controlling the number of times it is called, so there are only 3 instances for example?

I’d prefer a solution in the PHP if possible.

At the moment I’m storing the flag as a value in a database, is using a lock type file any better as in here https://stackoverflow.com/questions/851872/does-a-cron-job-kill-last-cron-execution ?

  • 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-14T20:11:33+00:00Added an answer on May 14, 2026 at 8:11 pm

    I used a dirty way of tracking the number of the scripts being executed via a table in a database. A launched script inserts a row with an id and the field started_time. On exit it removes his row. Too old rows are considered as “failed\dead scripts”.

    The worker scripts aren’t launched by cron directly. Cron launches “the launcher script” every 1 second or so, which checks the table for the number of active workers and spawns more workers if needed.

    Such a scheme is working online for me for 2.5 years already. Just grabbing some constantly updated content.

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

Sidebar

Related Questions

I have a daily cron job that email PDFs to customers. I want to
We have a cron job that runs once a day and sends daily emails
I have a cron job that emails a list of users monthly. The cron
I have written a Perl script that runs as a daily crontab job that
I have some python scripts that run on a daily basis in cron. How
I have a few files waiting to be processed by a daily cron job:
I have a cron task that runs once a day, using Heroku's Daily Cron
In my events table there are records that have a daily flag that indicate
We have a daily maintenance plan in SQL Server 2005 that performs a full
I have this nice little MSBuild-based daily build setup that I use on my

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.