使用gsutil cp向GCP运行powershell脚本可显示多行上传进度

问题描述 投票:1回答:1

我有一个简单的PowerShell脚本,它运行在我的Win'2008R2系统上的任务调度程序,基本上只运行以下命令:

gsutil -o GSUtil:parallel_composite_upload_component_size = 0 cp -L C:\ logs \ log1.txt C:\ archive \ * .zip gs:// temp

我正在使用Start-Transcript将输出记录到results.log文件中。问题是,当它将zip文件上传到gcp时,它会在上传过程中每隔64KB记录多行的进度:

Resuming upload for file://E:\db\db1.zip
Uploading   gs://temp/db1.zip:             0 B/1.20 GiB
Uploading   gs://temp/db1.zip:             98.75 MiB/1.20
Uploading   gs://temp/db1.zip:             98.81 MiB/1.20
...and keeps repeating this until it uploads the entire 1.20 GB.

由于results.log文件随后通过电子邮件发送给一群人,我不需要他们看到所有这些垃圾。只显示最终文件大小的一行就足够了。

当我使用:powershell.exe -file c:\ scripts \ upload.ps1从Windows命令提示符(或本机powershell)运行命令或脚本时,它按预期工作,显示单行上的进度:

Resuming upload for file://E:\db\db1.zip
Uploading   gs://temp/db1.zip:             1.20 GiB/1.20 GiB

之前,当我在没有'-o GSUtil:parallel_composite_upload_component_size = 0'参数的情况下运行相同的命令时,它显示了相同的长输出,但是一旦我将它添加到gsutil,我认为它很好,因为它不再重复进度了在PS命令提示符中的一堆行。所以只有当我从Task Scheduler运行脚本时才会发生这种情况。

任何想法为什么会发生这种情况,我该如何解决这个问题呢?

powershell gsutil
1个回答
1
投票

an open feature request in the gsutil repository, issue #481,当输出被定向到不是交互式终端的东西时禁用进度微调器。

© www.soinside.com 2019 - 2024. All rights reserved.