How should you run a shutdown handler before a preemptible Compute Engine Linux VM is preempted?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a shutdown script and set it as the instance metadata entry with key shutdown-script when creating the VM.
Why this is the answer
The correct method for running a shutdown handler before a preemptible VM is preempted is to use a shutdown script specified in the instance metadata. Google Compute Engine automatically executes scripts provided via the shutdown-script metadata key when an instance receives a shutdown signal, which includes preemption events. This ensures your script runs to perform cleanup tasks like saving data or gracefully stopping services. The other options are incorrect because: Creating a script in /etc/rc.6.d/ is a standard Linux shutdown mechanism, but it doesn't guarantee execution specifically for a Compute Engine preemption event in the same managed way as the metadata script. Using xinetd services and Stackdriver endpoint checks are for network-based service management and monitoring, not for handling VM preemption signals. gcloud compute instances add-metadata is for adding metadata, but shutdown-script-url is not a standard or supported metadata key for this purpose; the correct key is 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