I am new to SSH & cronjobs so probably I am doing something wrong.
I am using a Google Cloud Engine for hosting my SSH Linux instance and I want to delete a snapshot by its name with a cronjob (I have also a create snapshot cronjob that works fine).
So I wrote this script:
1 * * * * sudo gcloud compute snapshots delete my-snapshot-name -q
This script should delete the snapshot every 1 minute (the 1 minute is just in order to see the result immediately after I will see it works, I will change it accordingly).
The snapshot is not deleted.
If I run the same script, not in the cronjob then it deletes it:
sudo gcloud compute snapshots delete my-snapshot-name -q
/tmp/crontab.xxxxxx/crontab
, I click enter and the cronjob is created. What am I doing wrong? What could be the cause that the delete does not work?
It's better to add this to root crontab than using sudo.
Not so familiar with GCE, however a few things to try,
1) Use the complete path to the gcloud binary
2) Check /var/log/syslog for 'CRON' and check what the error is.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.