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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:43:58+00:00 2026-06-03T06:43:58+00:00

Here’s my problem: In my database I have a requests table, which has a

  • 0

Here’s my problem:

In my database I have a requests table, which has a status field.
A cronjob runs every minute, looking for every request with a “pending” status. WHen it’s done processing the request it sets the status to “finished”.

Sometimes this cronjob takes over a minute to run, so two of the same cronjob are running. I need to make sure they don’t process the same request.

Right now I’m doing this:

$requests = db_all($this->db->query('SELECT * FROM x__mx_request WHERE status="pending"'));
//few lines of code later
$this->db->query('UPDATE x__mx_request SET status="processing" WHERE id IN('.implode(',', $ids).')');

I set the status to processing after I select it, which stops other scripts from processing it too, but Isn’t it possible that one script selects all requests, then a 2nd script selects all requests before the 1st script sets them to processing?

I’d like a more secure way of doing this!

EDIT: Thanks for the great answers, I’ll have to actually try them out though before I can mark one as correct.

  • 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-03T06:43:59+00:00Added an answer on June 3, 2026 at 6:43 am

    you can try to make a lock/unlock file so cronjobs can check to “know” if a job is/isn’t already running.
    also process pid could be used for identifying status of process in case something failed, not responding etc..

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

Sidebar

Related Questions

Here is an example: I have a file 1.js, which has some functions. I
Here is my problem : I have a post controller with the action create.
Here's a problem I ran into recently. I have attributes strings of the form
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my problem...I have a page that loads a list of clients and
Here's my proposed (very simplified to illustrate the problem space) design for a C#
Here's what I want to do: Given a table PeopleOutfit (id int primary key,
Here's the basic setup: I have a thin bar at the top of a
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the
Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'),

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.