Startup scripts
Last updated
Last updated
Startup scripts perform tasks during the initial startup process of your instances. They can be used to automatically configure your environment and workloads, alleviating manual setup. See Instance types & specifications for information on what Foundry installs by default on all instances.
Startup scripts only run the first time your instance starts up. Your startup script will not run again if your instance is relocated or preempted and allocated at a later time. You can use a systemd
service to . Learn more about relocation and preemption statuses .
You have the option to add a startup script each time you create a new reservation or spot bid. Startup scripts must be added before submitting your reservation or bid; they cannot be added later.
You can add a startup script to your reservation or bid in the Foundry console by attaching a bash or txt file or manually typing a script into the startup script field.
Startup scripts must start with #!/bin/bash
and are limited to a maximum length of 10,000 characters.
To access your start-up script from your instance, run the following command:
To access any start-up script logs from your instance, run the following command:
The startup script added when creating your reservation or spot bid is only executed the first time your instance starts up. It will not run again if your instance is relocated or preempted.
However, because Foundry preserves the boot disk for your spot instances until you fully terminate your spot bid, you can use systemd
services to implement logic that restarts your workload the next time your spot instances start up after being relocated or preempted. You can use your initial startup script to set up a systemd
service.
Here is a simple example of a startup script that creates a hello-world.sh
script and a systemd
service, startup.service
, which will run hello-world.sh
on all subsequent startups: