We use Google's cloud compute engine for some of our servers. I'm hoping someone will have some experience of scheduling tasks with gcloud!
I have written a windows batch script that creates snapshots of these servers. This is using the cloud SDK for Windows. When I double-click the script to run it interactively myself it works fine. Here are the contents of snapshots.bat:
cd "C:\Program Files (x86)\Google\Cloud SDK"
set snapshotdate=%date:~-4,4%%date:~-7,2%%date:~-10,2%
gcloud compute disks snapshot [sanitised]
When I try to run it via a scheduled task in Windows, nothing happens. Checking the task logs reveals this:
Task Scheduler started "{681b1f5f-265b-499d-bd36-7b1d5bfcc833}" instance of the "\Run daily snapshots gcloud compute" task for user "AD\ewan.mclean".
Task Scheduler launched action "C:\Windows\SYSTEM32\cmd.exe" in instance "{681b1f5f-265b-499d-bd36-7b1d5bfcc833}" of task "\Run daily snapshots gcloud compute".
Task Scheduler successfully completed task "\Run daily snapshots gcloud compute" , instance "{681b1f5f-265b-499d-bd36-7b1d5bfcc833}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 2147942401.
Task Scheduler successfully finished "{681b1f5f-265b-499d-bd36-7b1d5bfcc833}" instance of the "\Run daily snapshots gcloud compute" task for user "AD\ewan.mclean".
I've looked up the return code but it's very vague. I presume it has something to do with the way the initialisation of the cloud environment works with the user's profile etc. I have however set it to run as me with my password as a test:
Anyone have any suggestions, or a better way to do this?