为什么GCE上的命令在控制台终端上工作,而不是作为Cron作业

时间:2017-09-23 17:09:45

标签: cron google-compute-engine

我可以使用Web控制台在我的实例上运行此命令;

  

gsutil rsync -d -r / my-path gs:// my-bucket

但是当我尝试使用我的远程ssh终端时,我收到了这个错误;

root@instance-2: gsutil rsync -d -r /my-path gs://my-bucket
Building synchronization state...
INFO 0923 12:48:48.572446 multistore_file.py] Error decoding credential, skipping
    Traceback (most recent call last):
      File "/usr/lib/google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/multistore_file.py", line 381, in _refresh_data_cache
        (key, credential) = self._decode_credential_from_json(cred_entry)
      File "/usr/lib/google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/multistore_file.py", line 400, in _decode_credential_from_json
        credential = Credentials.new_from_json(json.dumps(cred_entry['credential']))
      File "/usr/lib/google-cloud-sdk/platform/gsutil/third_party/oauth2client/oauth2client/client.py", line 292, in new_from_json
        return from_json(s)
      File "/usr/lib/google-cloud-sdk/platform/gsutil/third_party/apitools/apitools/base/py/credentials_lib.py", line 356, in from_json
        data['token_expiry'], oauth2client.client.EXPIRY_FORMAT)
    TypeError: must be string, not None
    Caught non-retryable exception while listing gs://my-bucket/: Could not reach metadata service: Not Found
    At source listing 10000...
    At source listing 20000...
    At source listing 30000...
    At source listing 40000...
    CommandException: Caught non-retryable exception - aborting rsync

1 个答案:

答案 0 :(得分:2)

我通过将用户切换到创建项目时创建的默认CGE来解决了这个问题。 VM上的root用户似乎没有运行gsutil命令的权限。