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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:31:37+00:00 2026-05-17T19:31:37+00:00

I have two web servers. Server ‘A’ and server ‘B’. Both are exact duplicate

  • 0

I have two web servers. Server ‘A’ and server ‘B’. Both are exact duplicate of the other and are connected to a load-balancer for serving clients.

I have a tasks (cronjob) that is executed at every hour, every day. This task is currently running only on server ‘A’. The problem is that this tasks is really important and if server ‘A’ crash for some reason the task will no longer run.

I would like server ‘B’ to execute the task but only if server ‘A’ didn’t.
Both tasks are PHP scripts interacting with a MySQL database.

I’m thinking about using some rows in a table (using MySQL locks?) as a flag for the server ‘B’ to start his task if server ‘A’ didn’t do it and vice versa.

Please note that the task file on both servers must be exactly the same.

Thank you.

  • 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-17T19:31:38+00:00Added an answer on May 17, 2026 at 7:31 pm

    Your proposed solution is one I often employ for simpler tasks, usually with something like:

    • cronjob is started on both servers alike
    • both get different tokens (something based on server-id & process-id usually)
    • both try to claim a job in a table with UPDATE jobs SET process = '$token' WHERE process IS NULL (+ some other clauses not to the point right now).
    • both check for processes won/claimed: SELECT * FROM jobs WHERE process = '$token'
    • only the ‘winner’ performs the job, loser / jobless process just exits.

    Something to keep in mind though that this only works for jobs as long as the MySQL instance is up: no processing can be done without it. Then again, a cronjob which checks whether the MySQL server is alive can be performed on both servers, I don’t mind to get 2 alerts for such a major catastrophe 🙂

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

Sidebar

Related Questions

I have two grails servers: Server - has read/write access to the database Web
I have an application that is load balanced across two web servers (soon to
On my Unix web server, I have two MySQL database servers running. One on
I have two webapps: a web-service client and a server (both CXF-based, using the
I have two web applications in the same server like this: /basedir/app1path/default1.aspx /basedir/app2path/default2.aspx How
I currently have an asp.net website hosted on two web servers that sit behind
I have two web applications and both are developed in ASP.NET. Now I want
I have two medium-sized web applications that I'm merging into one. They are both
Suppose you have two seperate ASP.NET Web Application projects that both need to use
We host our ASP.NET applications on two web servers (Server 2003, IIS 6) that

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.