Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write a script that runs on a server and looks for a configuration file every x seconds and starts or kills other scripts depending on the data in the configuration file. My question now is: When somebody uploads this configuration file via ftp could it be that my script just gets a part of this configuration data if the upload is not jet finished. How can I ensure that I never get a broken (= not yet complete uploaded) configuration file?

share|improve this question
up vote 1 down vote accepted

It may well be possible to get a broken file, especially if they're quite large. If they're really small (a few lines) it's not very likely. You have to think about what happens if you read it while a new one is being uploaded, or if something interrupts the upload.

One way of dealing with this kind of thing is to upload the file to a temporary name, then rename it to replace the real one. That way the real one is never incomplete.

While you can do this from the client, it's a bit inconvenient if the uploads are manual. (great if they're automatic though).

Quite a few FTP servers will take care of this for you, though.

For example ProFTPD has the configuration option HiddenStores:

NcFTPd has something similar:

Have a look through the manual for whichever FTP server you're using.

share|improve this answer
Thank you. As I read your I had the idea to ensure that the data is complete by storing the data in a format that could only be read if it is complete: I will store the configuration in json, so it won't be a problem. – stofl Oct 20 '11 at 10:02
that's an interesting idea, I don't see why it wouldn't work. – Colin Coghill Oct 20 '11 at 20:27

Take a look at mod_digest for ProFTPD.

share|improve this answer
How could this help me? I think it would be easier to use the hooks of the ftp server to run the script after the upload of the configuration file is finished. But I first would like to know if it is possible to get a broken file and how I can prevent this. – stofl Oct 19 '11 at 17:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.