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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:20:51+00:00 2026-06-15T15:20:51+00:00

I’m sorry I can’t fully focus my question. I’m trying to use flock to

  • 0

I’m sorry I can’t fully focus my question.

I’m trying to use flock to avoid from running the script concurrently, like described here in the accepted answer:
How to prevent a script from running simultaneously?

I remember someone saying that in this way there might be problems like not being able to run the script at all.

Does someone know about such a possibility?

I tried the following scenarios:

  1. Run the script right after it was run – it ran the second time
    perfectly
  2. Interrupt the script with CTRL+C and then run
    it again – no problem with the second run
  3. Shut down the machine abruptly while the script is running, power on
    the machine and rerun the script – the same result: no problem

I couldn’t think about more complex possibilities.

  • 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-15T15:20:52+00:00Added an answer on June 15, 2026 at 3:20 pm

    As its name suggests, the flock utility wraps the flock(2) system call, whose documentation states that it associates the lock with the fd’s entry in the table of open files. Open files get removed when the last file descriptor is closed, and descriptors are themselves transient resources automatically cleaned up when the process exits in any fashion, including kill -9. Forcible shutdown of the machine wipes the whole state of the running system, so locks associated with opened files cannot survive that scenario either. Therefore a script that exits in a timely fashion should not block the system.

    One realistic possibility of blocking that comes to mind is the script having a bug that causes it to hang indefinitely, which will indeed prevent other instances from being able to run. If this is expected to occur in practice, it can be handled by writing out the script PID ($$) into the lock file immediately after acquiring the lock. Before the lock is acquired, the process that waits for the lock would specify a timeout using the -w option to flock. If the timeout expires, it would read the PID of the hanging lock owner from the lock file, kill the owner, and repeat the locking process.

    A theoretical problem is the hardcoded file descriptor number 200. If your script opens 200 files, or is spawned from a program that opens 200 files without the close-on-exec bit, you will clobber an existing file descriptor. This is highly unlikely to occur in practice.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from

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.