【发布时间】:2021-04-22 14:17:50
【问题描述】:
我正在尝试使用玉米作业执行脚本,当我在终端手动运行脚本时,该脚本按要求运行,但当我通过 cron 作业运行它时失败。如何让它通过 cron 运行?
错误:gcloud: command not found
#!/bin/bash
GCE_STATUS=$(gcloud compute instances list | awk '/my-gce-instance/' | awk '{print $NF}')
REQ_STATUS="TERMINATED"
if [[ $GCE_STATUS != $REQ_STATUS ]];
then
echo "Google Compute Engine is currently Running - Shutting Down the Instance"
gcloud compute instances stop my-gce-instance --zone=us-central1-a
else
echo "Google Compute Engine is Already TERMINATED!!"
fi
【问题讨论】:
-
看起来你已经知道怎么做了,但是,这现在是 GCE 的一个内置功能:cloud.google.com/compute/docs/instances/…
标签: linux shell google-cloud-platform google-compute-engine