简体   繁体   English

在GCP实例终止时运行脚本

[英]Run script on GCP instance terminate

I would like to execute the shutdown script in case GCP compute instance is deleted by any means. 我想执行关闭脚本,以防万一GCP计算实例被删除。 I dont want to execute it in case instance is stopped. 我不想在实例停止的情况下执行它。

Is there any way to achieve this please? 有什么办法可以做到这一点?

I am new to GCP and really dont have any clue if there is anything which can help me to achieve this. 我是GCP的新手,真的没有任何线索可以帮助我实现这一目标。

Thanks in advance. 提前致谢。

Sanjiv 桑吉夫

Yes, there is an implementation for startup scripts and one for shutdown scripts for instances that run compatible images. 是的,对于运行兼容映像的实例,有一种用于启动脚本的实现,一种用于关机脚本的实现。

Bot types of scripts can be entered in the instance metadata directly through the GUI or the cloud shell or, in a more tidy way, you can upload the script file to one of your buckets and provide the url with the key "startup-script-url" Bot类型的脚本可以直接通过GUI或云外壳直接输入到实例元数据中,或者,以更简洁的方式,您可以将脚本文件上传到您的存储桶之一,并为网址提供键“ startup-script-网址”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM