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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:48:22+00:00 2026-05-11T08:48:22+00:00

It’s a very common scenario: some process wants to drop a file on a

  • 0

It’s a very common scenario: some process wants to drop a file on a server every 30 minutes or so. Simple, right? Well, I can think of a bunch of ways this could go wrong.

For instance, processing a file may take more or less than 30 minutes, so it’s possible for a new file to arrive before I’m done with the previous one. I don’t want the source system to overwrite a file that I’m still processing.

On the other hand, the files are large, so it takes a few minutes to finish uploading them. I don’t want to start processing a partial file. The files are just tranferred with FTP or sftp (my preference), so OS-level locking isn’t an option.

Finally, I do need to keep the files around for a while, in case I need to manually inspect one of them (for debugging) or reprocess one.

I’ve seen a lot of ad-hoc approaches to shuffling upload files around, swapping filenames, using datestamps, touching ‘indicator’ files to assist in synchronization, and so on. What I haven’t seen yet is a comprehensive ‘algorithm’ for processing files that addresses concurrency, consistency, and completeness.

So, I’d like to tap into the wisdom of crowds here. Has anyone seen a really bulletproof way to juggle batch data files so they’re never processed too early, never overwritten before done, and safely kept after processing?

  • 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-11T08:48:23+00:00Added an answer on May 11, 2026 at 8:48 am

    The key is to do the initial juggling at the sending end. All the sender needs to do is:

    1. Store the file with a unique filename.
    2. As soon as the file has been sent, move it to a subdirectory called e.g. completed.

    Assuming there is only a single receiver process, all the receiver needs to do is:

    1. Periodically scan the completed directory for any files.
    2. As soon as a file appears in completed, move it to a subdirectory called e.g. processed, and start working on it from there.
    3. Optionally delete it when finished.

    On any sane filesystem, file moves are atomic provided they occur within the same filesystem/volume. So there are no race conditions.

    Multiple Receivers

    If processing could take longer than the period between files being delivered, you’ll build up a backlog unless you have multiple receiver processes. So, how to handle the multiple-receiver case?

    Simple: Each receiver process operates exactly as before. The key is that we attempt to move a file to processed before working on it: that, and the fact the same-filesystem file moves are atomic, means that even if multiple receivers see the same file in completed and try to move it, only one will succeed. All you need to do is make sure you check the return value of rename(), or whatever OS call you use to perform the move, and only proceed with processing if it succeeded. If the move failed, some other receiver got there first, so just go back and scan the completed directory again.

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

Sidebar

Ask A Question

Stats

  • Questions 142k
  • Answers 142k
  • 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 Try something like this: $('div.blueBoxMid ul li').each(function () { var… May 12, 2026 at 8:18 am
  • Editorial Team
    Editorial Team added an answer I think it's almost always preferable to have your views… May 12, 2026 at 8:18 am
  • Editorial Team
    Editorial Team added an answer You should be able to call $("#yourdate").datepicker() when handling your… May 12, 2026 at 8:18 am

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
It seems to me obfuscation is an idea that falls somewhere in the security

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.