有没有办法在 Google Cloud Platform 中安排 Cloud Shell 命令?

Is there a way to schedule Cloud Shell commands in Google Cloud Platform?

我想安排我在 Cloud Shell CLI 中执行的一些 BigQuery table 加载命令。如何在 Google Cloud Platform 中安排我的 CLI 命令?

Cloud Shell 不是一种旨在用作生产环境的一部分的工具,您应该了解一下它的 terms and conditions。你可能会发现这部分特别阻塞了这个目的:

Non-interactive sessions will be ended automatically after a warning. Note that Cloud Shell sessions are capped at 12 hours, after which sessions are automatically terminated.

您实际上可以做的是创建一个 Cloud Function 并通过 cron 作业触发它或使用 Compute Engine 实例和 schedule a command on linux

  1. 使用 Cloud Scheduler 到 shell 个作业,例如 HTTP 触发器。
  2. 创建 Cloud Run container running the commands you want on HTTP trigger. Here is an example

此解决方案是无服务器的,仅在触发时运行。 Cloud 运行 允许免费请求 2M。 Cloud Scheduler 允许每个帐户每月免费执行 3 个作业,然后 Cost/job/month 0.10 美元。