Newbis
asked on
Stuck file with WinSCP script and OpenSSH on Windows 2000 Server
A company I do some business with has a WinSCP script that uploads a file nightly using SFTP, overwriting it if it's there. They also have another similar script that transfers the file to a different server and deletes the original file. (I think the machines are running Windows 2000 Server, with OpenSSH to provide SFTP functionality.)
Unfortunately, at some point, Windows said that the file was in use, and it couldn't be deleted. Attempting to delete it manually gave a File In Use error. Hence, both scripts failed to function properly.
However, after I ran a WinSCP script to upload the file with a different name, the lock on the original file was mysteriously removed, and I was able to delete any remnants of the file.
Therefore, I suspect that WinSCP or OpenSSH somehow had a handle to the file that was released by running another WinSCP script successfully.
This is the first time that happened with these scripts, which had been running for years without ever encountering this specific problem before. Nevertheless, I would be interested in any ideas about how to prevent this sort of thing in the future. Obviously, one could have a script that keeps changing the filename (e.g., appending 1, 2...) if it gets a "file in use" error. But I wonder if there's a simpler or more elegant/direct way.
Unfortunately, at some point, Windows said that the file was in use, and it couldn't be deleted. Attempting to delete it manually gave a File In Use error. Hence, both scripts failed to function properly.
However, after I ran a WinSCP script to upload the file with a different name, the lock on the original file was mysteriously removed, and I was able to delete any remnants of the file.
Therefore, I suspect that WinSCP or OpenSSH somehow had a handle to the file that was released by running another WinSCP script successfully.
This is the first time that happened with these scripts, which had been running for years without ever encountering this specific problem before. Nevertheless, I would be interested in any ideas about how to prevent this sort of thing in the future. Obviously, one could have a script that keeps changing the filename (e.g., appending 1, 2...) if it gets a "file in use" error. But I wonder if there's a simpler or more elegant/direct way.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
We have had similar situations where a process has disappeared (perhaps died, at least you can't find it) leaving files open. Obviously by rebooting every day reduces the risk, but many of our customers don't daily reboot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found what was likely causing WinSCP to cause the file to have an open handle to it. My intention in asking the question was to figure out what was the causing the problem and potentially how to prevent that, not just how to make the solution more robust in case there's a problem, which I know also needs to be done.
ASKER