7

I have two drives A and B. Using a python script I am creating some files in "A" drive and I am running a powerscript which copies all the files in the drive A to drive B in the interval of 1 sec.

I am getting this error in my powershell.

2015/03/10 23:55:35 ERROR 32 (0x00000020) Time-Stamping Destination File \x.x.x.x\share1\source\ Dummy_100.txt The process cannot access the file because it is being used by another process. Waiting 30 seconds...

How will I overcome this error?

Bjoern
  • 15,934
  • 4
  • 43
  • 48
rabi shaw
  • 441
  • 1
  • 3
  • 14

4 Answers4

4

if you want to skip this files you can use /r:n that n is times of tries for example /w:3 /r:5 will try 5 time every 3 seconds

heck1
  • 714
  • 5
  • 20
3

This happened is because the file is locked by running process. To fix this, download Process Explorer. Then use Find>Find Handle or DLL, find out which process locked this file. Use 'taskkill' to kill that process in commandline. You will be fine.

Oseack
  • 181
  • 2
  • 5
2
How will I overcome this error?

If backup is, what you got in mind, and you encounter in-use files frequently, you look into Volume Shadow Copies (VSS), which allow to copy files despite them being ‘in use’. It's not a product, but a windows technology used by various backup tool.

Sadly, it's not built into robocopy, but can be used in conjunction with it. See

https://superuser.com/a/602833/75914

and especially:

https://github.com/candera/shadowspawn

Community
  • 1
  • 1
Frank N
  • 9,625
  • 4
  • 80
  • 110
1

It could be many reasons.

In my case, I was running a CMD script to copy from one server to another, a heap of SQL Server backups and transaction logs. I too had the same problem because it was trying to write into a log file that was supposedly opened by another process. It was not.

I ran many IP checks and Process ID checkers that I ran out of knowing what was hogging the log file. Event viewer said nothing.

I found out it was not even the log file that was being locked. I was able to delete it by logging into the server as a normal user with no admin privileges!

It was the backup files themselves by the SQL Server Agent. Like @Oseack said, there may have been the need to use another tool whilst the backup files themselves were still being used or locked by the SQL Server Agent.

The way I got around it was to force ROBOCOPY to wait.

/W:5

did it.

Fandango68
  • 4,461
  • 4
  • 39
  • 74