Is there a way to run a command via fly ssh against all app instances?

Wondering if there’s a compact method from the flyctl cli to run a single bash command against all instances of an active app and get the results to stdout.


1 Like

This an interesting question and I think the current way to do this is looping through the result of fly status and running fly ssh console -C for each VM but on other hand can I ask you what are you trying to accomplish to see if there’s another way we can help you with that?


Thanks @lubien – we recently need to do diagnostics, comparison & debugging on live instances, and have a 10-instance app. Manually SSHing into each ended up being the route, but less than convenient, and wondered if I was missing a better method should the need arise again.

I was thinking it could be something on these lines. May I suggest you use health checks?

The tl;dr: you can create a route that replies with plain text with the infos you’d want to know and it would be available under your app Monitoring Page and fly checks list. We been doing work improving those (see Health check history on Monitoring Page) and we even use this for customers postgres to show useful data like status for each node. Here’s how it looks like from another post

If you also happen to need to collect those checks you can do so by the machines list API endpoint (assuming you use machines, they’re awesome).

Let me know if these might fix your use case.

1 Like

@lubien I appreciate you pointing out the health check and monitoring page improvements that have been made. They really aren’t what I’m looking for in this case, but look promising for some other items we may need.

In this scenario I’m really just looking for a way to run an adhoc shell command against all our instances and pipe the results to the stdout. Sounds like I need to write something to combine fly status & fly ssh.

Thanks for your time!

  • andrew
1 Like

The Machines API has an /exec endpoint that may make this simpler. If you need to run a one off command and get quick stdout/stderr, it’s slick. It won’t work well if you need streaming responses, though.

1 Like

@kurt roger that – I’m only using machines for a PG cluster at the moment. The mental wrapping of my head around VMs → machines is slow and lizard-like.

Next you’ll tell me “the cloud” is not actually running on my computer.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.