GCP - Initate a shutdown to an instance after certein time when it started for example 3 hours after started

0 votes

I have instances in GCP. I can schedule a time to start and stop using the scheduler. But, I don't want a specific time of the day, I want a specific time after instance was started.

For example - Stop the instance after 8 hours the instance is up and running.

Mar 30, 2022 in GCP by Rahul
• 3,380 points
905 views

1 answer to this question.

0 votes

You can add the contents of a startup script directly to a VM when you create the VM,

You can also pass a Linux startup script directly to an existing VM:

In your Cloud Console go to VM Instance page and click on the instance you want to pass the startup script 

  1. Click Edit 
  2. Under Automation specify the following:
 #! /bin/bash
shutdown -P +60

- P instructs the system to shut down and then power down.

The time argument specifies when to perform the shutdown operation.

The time can be formatted in different ways.

Firstly it can be an absolute time in the format hh:mm where hh is the hour and mm is the minute of the hour.

Secondly it can be of the format +m where m is the number of minutes to wait.

Also, the word now is the same as specifying +0; it shuts the system down immediately. 

answered Mar 31, 2022 by Korak
• 5,820 points

Related Questions In GCP

0 votes
1 answer
0 votes
1 answer

Connect to an instance as a root user in GCP

If you configured an instance to allow ...READ MORE

answered Sep 24, 2019 in GCP by Sirajul
• 59,230 points
5,441 views
0 votes
1 answer
0 votes
1 answer

Is it possible to create an instance with a boot disk that is smaller than 10GB?

You would probably encounter the following error: Disk ...READ MORE

answered Nov 4, 2019 in GCP by Sirajul
• 59,230 points
1,039 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Bottleneck while uploading lots of files to GCP bucket in a small time

You might have a hotspot on Cloud ...READ MORE

answered Mar 17, 2022 in GCP by Korak
• 5,820 points
1,290 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP