在 crontab 中的 bash 脚本中执行 gcloud 命令时出错

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

我编写了一个 bash 脚本,使用 用于激活服务帐户的 gcloud 命令和 gsutil 命令将文件移动到 GCS 存储桶。 当我使用 bash 命令运行脚本时,它执行得很好。但是当我将脚本放入 crontab 时,它会失败并显示命令未找到。

==> NOTE: You are uploading one or more large file(s), which would run
significantly faster if you enable parallel composite uploads. This
feature can be enabled by editing the
"parallel_composite_upload_threshold" value in your .boto
configuration file. However, note that if you do this large files will
be uploaded as `composite objects
<https://cloud.google.com/storage/docs/composite-objects>`_,which
means that any user who downloads such objects will need to have a
compiled crcmod installed (see "gsutil help crcmod"). This is because
without a compiled crcmod, computing checksums on composite objects is
so slow that gsutil disables downloads of composite objects.

Removing file:///file.csv
Operation completed over 1 objects/2.7 GiB.
/script.sh: line 691: gcloud: command not found
/script.sh: line 693: gsutil: command not found 

这里有什么错误。我该如何纠正

bash shell cron gcloud gsutil
1个回答
0
投票

问题出在 PATH 上。感谢下面的回答。它在脚本中显式导出 gcloud 路径后起作用。 gcloud 命令未找到 - 安装 Google Cloud SDK 时

export PATH="~/google-cloud-sdk/bin:$PATH"
© www.soinside.com 2019 - 2024. All rights reserved.