0

I've got an application that is watching file move atomically to a specific directory.

When doing a sftp from a RedHat linux server, uploading a file to a tmp dir, them moving it with the "rename" sftp to the final dir, my application well sees the new file.

On the same server, but when uploading via sftp from a Solaris server with the same process (upload to tmp dir then "rename" the name to final dir), my application does not see the file. It seems that Solaris sftp client "rename" command does not do an atomic move.

Is it well the case? Is there a way I can do an atomic move from Solaris via sftp?

Best regards, Raoul

0

rename() is always atomic on both Linux and Solaris - but rename() always fails when the rename() is done across file systems.

For an [s]ftp rename command to be an atomic operation on both Linux and Solaris server and not a file copy, the old and new file names must be on the same filesystem so the rename() system call can succeed.

Assuming your "tmp dir" on the Solaris system is actually /tmp, that will be on a separate file system. Whatever your "tmp dir" is on the Linux either happens to be on the same filesystem as the final directory, or you're just not noticing any lack of atomicity in the sftp rename command.

You need to ensure your "tmp dir" and the final directory are on the same filesystem.

| improve this answer | |
  • Thanks Andrew, My Tmp dir is on the same filesytem of my final dit. What I don’t understand is in both case, sftp fron RHEL 7 and Solaris, we are doing the same sftp command on same dir, but result is different – Raoul Debaze May 1 '19 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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