Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stantonk
Created February 27, 2013 21:43
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save stantonk/5052027 to your computer and use it in GitHub Desktop.
Save stantonk/5052027 to your computer and use it in GitHub Desktop.
Unified tail -f of a log file across multiple hosts via ssh.
#!/bin/bash
HOSTS=(PUT, YOUR, HOSTS, HERE)
CMD="tail -f logs/api.log"
echo "Hit CTRL-C to stop"
sleep 0.5
PIDS=""
for host in ${HOSTS[*]}
do
ssh $host $CMD &
PIDS="$PIDS $!"
done
trap 'kill $PIDS' SIGINT
wait
@ChiassonFaminect
Copy link

you're the man my man! ^-^
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment