I am trying to trying to execute a script using corn job, the script runs as required when i run it manually at the terminal but fails when i run it through a cron job. How can i make it run via cron?
Error: 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