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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:37:25+00:00 2026-05-10T20:37:25+00:00

I’m betting that someone has already solved this and maybe I’m using the wrong

  • 0

I’m betting that someone has already solved this and maybe I’m using the wrong search terms for google to tell me the answer, but here is my situation.

I have a script that I want to run, but I want it to run only when scheduled and only one at a time. (can’t run the script simultaneously)

Now the sticky part is that say I have a table called ‘myhappyschedule’ which has the data I need and the scheduled time. This table can have multiple scheduled times even at the same time, each one would run this script. So essentially I need a queue of each time the script fires and they all need to wait for each one before it to finish. (sometimes this can take just a minute for the script to execute sometimes its many many minutes)

What I’m thinking about doing is making a script that checks myhappyschedule every 5 min and gathers up those that are scheduled, puts them into a queue where another script can execute each ‘job’ or occurrence in the queue in order. Which all of this sounds messy.

To make this longer – I should say that I’m allowing users to schedule things in myhappyschedule and not edit crontab.

What can be done about this? File locks and scripts calling scripts?

  • 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. 2026-05-10T20:37:26+00:00Added an answer on May 10, 2026 at 8:37 pm

    add a column exec_status to myhappytable (maybe also time_started and time_finished, see pseudocode)

    run the following cron script every x minutes

    pseudocode of cron script:

    [create/check pid lock (optional, but see 'A potential pitfall' below)] get number of rows from myhappytable where (exec_status == executing_now) if it is > 0, exit begin loop   get one row from myhappytable     where (exec_status == not_yet_run) and (scheduled_time <= now)     order by scheduled_time asc   if no such row, exit   set row exec_status to executing_now (maybe set time_started to now)   execute whatever command the row contains   set row exec_status to completed   (maybe also store the command output/return as well, set time_finished to now) end loop [delete pid lock file (complementary to the starting pid lock check)] 

    This way, the script first checks if none of the commands is running, then runs first not-yet run command, until there are no more commands to be run at the given moment. Also, you can see what command is executing by querying the database.

    A potential pitfall: if the cron script is killed, a scheduled task will remain in ‘executing_now’ state. That’s what the pid lock at beginning and end is for: to see if the cron script terminated properly. pseudocode of create/check pidlock:

    if exists pidlockfile then   check if process id given in file exists   if not exists then     update myhappytable set exec_status = error_cronscript_died_while_executing_this          where exec_status == executing_now     delete pidlockfile   else (previous instance still running)     exit   endif endif create pidlockfile containing cron script process id 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are right about the webservices are a bit more… May 12, 2026 at 12:55 am
  • Editorial Team
    Editorial Team added an answer Update (2017) Modern browsers now consider displaying a custom message… May 12, 2026 at 12:55 am
  • Editorial Team
    Editorial Team added an answer The problem was the connection string ..... "Data Source=\\\Program Files\xx\DB.sdf"… May 12, 2026 at 12:55 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.