Last active
March 29, 2017 11:21
-
-
Save danielRomero/e22bb4aceb3444315dfc2403b4e29baf to your computer and use it in GitHub Desktop.
Execute command in all AWS EC2 instances with capistrano
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get all hosts (change regex to fit your structure) | |
targets=($(cap production ec2:status | egrep -o "ec2.*com")) | |
for host in `echo $targets` | |
do | |
echo fetching logs from ${host} | |
# Command to execute (example, download logs from all machines) | |
scp ubuntu@${host}:/var/www/my_app_name/shared/log/production.log ./production${host}.log | |
done | |
echo done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment