1

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:

enter image description here

enter image description here

Anyone have any suggestions, or a better way to do this?

Desperatuss0ccus
  • 252
  • 1
  • 4
  • 9
  • When you find a solution please post your answer, unless some else answers to this question. I'm also interested how to achieve this. I was thinking to use their API and run a python or a php script (cron job that would do that). – el.severo Apr 09 '16 at 23:44
  • 1
    Tagging this as google-cloud-platform only may reduce visibility, as this is a general problem with running batch files from the Windows task scheduler. The answers http://stackoverflow.com/a/13173752/3953357 and http://serverfault.com/a/734054/286003 may help. – Adam Apr 10 '16 at 23:55

0 Answers0