开发者

Robocopy error code 6 ''The handle is invalid'

I have written a python script that uses subprocess to call robocopy to sync log files from a remote host.

Like so:

program = 'Robocopy'
options = ['/S']
args.append(program)
args.append(options)
args.append('\\\\%s\%s' % (hostname, source_path))
args.append(local_path)
proc = subprocess.Popen(args=args, shell=True, stdout=cmd_log, stderr=error_log) 

where source_path is the path on the remote host and local_path is the path on local host (both UNC paths). The code typically runs in a daemon process and gets kicked off every few hours. It is also possible to runs this code directly on the command prompt. It appears that sometimes when it is running in a daemon process I get an error from Robocopy:

开发者_Go百科

Error code 6: 'The handle is invalid'

But when I run this on the command prompt I get no errors. From what I found in a web search this may be related to file handles that are already open on the files being transferred. Does anyone have more information on this error and ways to avoid it?


Google searches for "robocopy handle is invalid" suggest you might find success by using the /b option for "backup mode".

Even if that doesn't work, I'd suggest adding code to output the filenames as they are being copied (or log it), and once you've identified the specific failing file, you may well also realize what the problem is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜