Get -Delete Command Not Deleting Files Intermittently

Advertisement

RyanBlakeIT
Donor
Joined:
Posts:
1
Location:
Virginia, USA

Get -Delete Command Not Deleting Files Intermittently

I have a script that does get -delete * and sometimes it will not delete the file because it says it's still in use on the server.

Here's a snippet of the log:
. 2023-04-18 11:30:04.250 Changing directory to "/Some/Irrelevant/Path".
. 2023-04-18 11:30:04.266 Getting current directory name.
< 2023-04-18 11:30:04.266 Script: /Some/Irrelevant/Path
> 2023-04-18 11:30:04.266 Script: get -delete * .\
. 2023-04-18 11:30:04.266 Listing directory "/Some/Irrelevant/Path".
. 2023-04-18 11:30:04.290 Trying to open directory "/Some/Irrelevant/Path".
. 2023-04-18 11:30:04.331 Getting current directory name.
< 2023-04-18 11:30:04.331 Script: /Some/Irrelevant/Path
> 2023-04-18 11:30:04.332 Script: get -delete * .\
. 2023-04-18 11:30:04.332 Listing directory "/Some/Irrelevant/Path".
. 2023-04-18 11:30:04.479 Copying 1 files/directories to local directory ".\" - total size: 3,917
. 2023-04-18 11:30:04.479 File: '/Some/Irrelevant/Path/SomeFile-en-us.xlsx' [2023-04-18T14:02:00.000Z] [3917]
. 2023-04-18 11:30:04.479 Copying "/Some/Irrelevant/Path/SomeFile-en-us.xlsx" to local directory started.
. 2023-04-18 11:30:04.482 Opening remote file.
. 2023-04-18 11:30:04.532 Copying 1 files/directories to local directory ".\" - total size: 3,917
. 2023-04-18 11:30:04.532 File: '/Some/Irrelevant/Path/SomeFile-en-us.xlsx' [2023-04-18T14:02:00.000Z] [3917]
. 2023-04-18 11:30:04.533 Copying "/Some/Irrelevant/Path/SomeFile-en-us.xlsx" to local directory started.
. 2023-04-18 11:30:04.533 Opening remote file.
. 2023-04-18 11:30:04.716 Copying 1 files/directories to local directory ".\" - total size: 3,917
. 2023-04-18 11:30:04.716 File: '/Some/Irrelevant/Path/SomeFile-en-us.xlsx' [2023-04-18T14:02:00.000Z] [3917]
. 2023-04-18 11:30:04.716 Copying "/Some/Irrelevant/Path/SomeFile-en-us.xlsx" to local directory started.
. 2023-04-18 11:30:04.716 Opening remote file.
. 2023-04-18 11:30:04.756 Preserving timestamp [2023-04-18T14:02:00.000Z]
. 2023-04-18 11:30:04.756 Transfer done: '/Some/Irrelevant/Path/SomeFile-en-us.xlsx' => 'C:\Cognos\INCOMING\SomeFile-en-us.xlsx' [3917]
. 2023-04-18 11:30:04.756 Deleting file "/Some/Irrelevant/Path/SomeFile-en-us.xlsx".
. 2023-04-18 11:30:04.884 Confirming overwriting of file.
. 2023-04-18 11:30:04.974 Preserving timestamp [2023-04-18T14:02:00.000Z]
. 2023-04-18 11:30:04.974 Transfer done: '/Some/Irrelevant/Path/SomeFile-en-us.xlsx' => 'C:\Cognos\INCOMING\SomeFile-en-us.xlsx' [3917]
. 2023-04-18 11:30:04.974 Deleting file "/Some/Irrelevant/Path/SomeFile-en-us.xlsx".
* 2023-04-18 11:30:05.064 (EOSError) System Error.  Code: 32.
* 2023-04-18 11:30:05.064 The process cannot access the file because it is being used by another process
. 2023-04-18 11:30:05.064 Asking user:
. 2023-04-18 11:30:05.064 Error deleting file '/Some/Irrelevant/Path/SomeFile-en-us.xlsx'. ("Permission denied.
. 2023-04-18 11:30:05.064 Asking user:

. 2023-04-18 11:30:05.064 Can't create file '.\SomeFile-en-us.xlsx'. ("System Error.  Code: 32.
< 2023-04-18 11:30:05.064 Script: Error deleting file '/Some/Irrelevant/Path/SomeFile-en-us.xlsx'.
< 2023-04-18 11:30:05.064 Script: Can't create file '.\SomeFile-en-us.xlsx'.
< 2023-04-18 11:30:05.064 Script: System Error.  Code: 32.
< 2023-04-18 11:30:05.064 Script: Permission denied.
e file because it is being used by another process
< 2023-04-18 11:30:05.064 Error code: 3
< 2023-04-18 11:30:05.064 Error message from server (en): Permission denied
. 2023-04-18 11:30:05.113 Answer: Skip
. 2023-04-18 11:30:05.113 Copying finished: Transferred: 3,917, Elapsed: 0:00:00, CPS: 6,178/s
* 2023-04-18 11:30:05.113 (ESkipFile) Can't create file '.\SomeFile-en-us.xlsx'.
* 2023-04-18 11:30:05.113 System Error.  Code: 32.
* 2023-04-18 11:30:05.113 The process cannot access the file because it is being used by another process
. 2023-04-18 11:30:05.113 Copying finished: Transferred: 0, Elapsed: 0:00:00, CPS: 0/s
> 2023-04-18 11:30:05.113 Script: close
. 2023-04-18 11:30:05.113 Closing connection.
The company that manages the SFTP server is saying that our client is sending the commands too fast and is pushing it as our problem.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,253
Location:
Prague, Czechia

Re: Get -Delete Command Not Deleting Files Intermittently

I'd argue that it's their problem.
Anyway, if the server is not able to handle consecutive download and delete, then you cannot use get -delete with this particular server.

Either you can use:
get *
rm *
But that's not transactionally safe – you might end up deleting files you didn't download.

If you need transactionally safe solution, you will need to use more complex solution, like shown here: Deleting remote files after successful remote to local synchronization

Reply with quote

Advertisement

You can post new topics in this forum