Progress Indicator for DOCTL Commands

Posted December 9, 2019 1.3k views
Linux BasicsDigitalOceanDigitalOcean API and CLI (doctl)

I’m building a script that automatically will shutdown a droplet before it creates a snapshot, and then powers it back on.

The snapshot takes time to complete, but I think it would be great to see progress indicator. Any ideas on how to do this?

edited by AHA

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

When scripting with doctl you can pass the --wait flag to Droplet “action” commands in order to block until the action has completed. For example:

doctl compute droplet-action power-off --wait <droplet-id>

Unfortunately, as the API does not report back detailed progress information, creating an accurate progress indicator would not be possible. You can vote for this feature request on to show your support for that feature.

There are a number of different approaches you could take to add a spinner to indicate that the script is still working. This blog post is a good explanation of how these tend to work.