google-cloud-platform - 调度 gsutil 命令
问题描述
我正在使用 gsutil 将数据从本地机器文件加载到 GCS。但现在我想将它安排为 20 分钟间隔,数据将从本地机器导出到谷歌云存储。我们如何创建这种类型的 cron 作业以及应该在哪里创建我创造?
解决方案
您应该在本地计算机中创建一个脚本来完成此任务。
它可能看起来像这样(确保您授予文件可执行权限):
#! /bin/bash
PATH="$PATH":[REPLACE with /path/to/gsutil/]
# The ".boto" file contains the settings that helps you do operations with your bucket: https://cloud.google.com/storage/docs/boto-gsutil
export BOTO_CONFIG=[REPLACE with "/home/username/.boto"]
# upload the file with the relevant gsutil command
gsutil cp [Replace with OBJECT_LOCATION] gs://[REPLACE with DESTINATION_BUCKET_NAME]/
以下 cron 计划表达式:*/20 * * * *
应该每 20 分钟触发一次作业,因此编辑 crontab 文件crontab –e
并添加以下行:
*/20 * * * * [PATH-TO-SCRIPT]/[NAME-OF-SCRIPT].sh >/dev/null 2>&1
以下站点是您计算 cron 计划表达式的绝佳资源,这是一个关于如何使用 linux 设置 cronjob 的非常好的教程。
推荐阅读
- visual-studio-code - 如何在vs代码中导出api密钥
- azure-machine-learning-studio - Azure ML 教程 - 无法加载入口点 automl
- django - 使用 django-auth-ldap 包可以自动登录 ldap 吗?
- git - Github 存储库不使用 gh cli 克隆
- node.js - Node.js 无法读取 else if 或 else 部分
- python - 将一系列数字分类为素数或复合数
- macos - Visual Studio for Mac 覆盖蓝屏并且无法对其执行任何操作
- firebase - Android - 从实时数据库中的子节点获取位置值并显示用户半径内的标记
- c# - Ocelot Api 网关聚合
- llvm - 共享库错误:找不到符号:__ZN4llvm23EnableABIBreakingChecksE