You have created several pre-emptible Linux virtual machine instances using Google Compute Engine. You want to properly shut down your application before the virtual machines are preempted. What should you do?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a shutdown script and use it as the value for a new metadata entry with the key shutdown-script in the Cloud Platform Console when you create the new virtual machine instance.
Why this is the answer
The correct approach is to use a shutdown script specified via metadata. When a pre-emptible VM receives a preemption notice, it gets 30 seconds to shut down. During this grace period, the VM executes any scripts defined in the shutdown-script metadata key. This allows your application to perform cleanup tasks, such as saving state or flushing data, before the instance is stopped. Creating a script in /etc/rc.6.d/ is a standard Linux shutdown mechanism, but it doesn't specifically handle the preemption signal from Compute Engine. A xinetd service is for network-based services and isn't designed for VM shutdown events. While gcloud compute instances add-metadata can add metadata, the key shutdown-script-url is not the standard or correct key for a shutdown script; it should be shutdown-script.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed