By speedo1947
We have a use case where we need to keep the droplet running for a time period i.e. 8 am to 5 pm. The droplet should be stopped out of these working hours.
Currently we are doing manually. Is there any way to automate this?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @speedo1947,
I’ll suggest giving the DigitalOcean API a look:
You can use the following CURL Post request:
curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582" \
-d '{"type":"power_off"}' \
"https://api.digitalocean.com/v2/droplets/3164450/actions"
Just remember to replace b7d03a6947b217efb6f3ec3bd3504582 with your own API token and 3164450 with your Droplet’s ID.
Ofcourse, when you want to start the droplet, replace power_off with power_on.
Hi there,
In addition to what has already been mentioned, here are a few examples of how to use the DigitalOcean API with different types of programming languages:
The example is with a reboot, but you can change this to power_off and power_on accordingly.
Best, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.