Skip to content

Instantly share code, notes, and snippets.

@max-arnold
Created February 7, 2014 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max-arnold/8862627 to your computer and use it in GitHub Desktop.
Save max-arnold/8862627 to your computer and use it in GitHub Desktop.
Watch logs from multiple remote servers in single terminal window
MULTITAIL() {
if [ "$#" = "0" ]; then
echo "MULTITAIL logdir host1 host2 ..."
exit 1
fi
logdir=$1
shift
if [ "$#" = "0" ]; then
echo "no hosts specified"
exit 1
fi
args1="-CS apache -l 'ssh -t $1 \"tail -f $logdir/access.log \"'"
args2="-CS apache_error -l 'ssh -t $1 \"tail -f $logdir/error.log \"'"
shift
while [ "$#" != "0" ]; do
args1="$args1 -L 'ssh -t $1 \"tail -f $logdir/access.log \"'"
args2="$args2 -L 'ssh -t $1 \"tail -f $logdir/error.log \"'"
shift
done
echo "multitail $args1 $args2"
eval multitail $args1 $args2
}
@max-arnold
Copy link
Author

Usage:

MULTITAIL /path/to/web/logs host1 host2 host3 ...

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