Created
February 7, 2014 13:28
-
-
Save max-arnold/8862627 to your computer and use it in GitHub Desktop.
Watch logs from multiple remote servers in single terminal window
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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: