Skip to content

Instantly share code, notes, and snippets.

@skiold
Forked from stantonk/multitail.sh
Created December 11, 2017 10:33
Show Gist options
  • Save skiold/8d39a82198be2979744198ee7525c97b to your computer and use it in GitHub Desktop.
Save skiold/8d39a82198be2979744198ee7525c97b 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment