Created
April 16, 2014 21:58
-
-
Save luke10x/10937274 to your computer and use it in GitHub Desktop.
Syncs new lines in a remote log file to a local file then outputs it through tailable
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 | |
# Syncs new lines in a remote log file to a local file. | |
# Downloads remote file, and prints all lines that are | |
# not yet printed | |
source=$1 | |
# Find the name for the locally copied file | |
hash=`echo "$source" | md5sum | cut -d " " -f 1` | |
mkdir -p ~/.tailable/temp/local-mirror | |
local_copy="$(readlink -f ~/.tailable/temp)/$hash" | |
# Copy remote file | |
timeout 3 scp "$source" "$local_copy" 1>/dev/null | |
error_code=$? | |
if [ "$error_code" -ne "0" ]; then | |
echo "`date` Failed to download file from '$source'" 1>&2 | |
exit $error_code | |
fi | |
./tailable -f "$local_copy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment