Skip to content

Instantly share code, notes, and snippets.

@oremj
Created November 13, 2009 00:53
Show Gist options
  • Save oremj/233476 to your computer and use it in GitHub Desktop.
Save oremj/233476 to your computer and use it in GitHub Desktop.
log fetch script
#!/bin/bash
function create_lock {
LOCK_NAME=$1
if [[ -e "$LOCK_NAME" ]]
then
OLDPID=`cat $LOCK_NAME`
if ps p $OLDPID > /dev/null
then
return 1
fi
rm $LOCK_NAME
fi
echo $$ > $LOCK_NAME
return 0
}
HOSTNAME=$1
LOCKFILE=/tmp/$1.logpull.lock
if ! create_lock $LOCKFILE
then
exit 1
fi
rsync -aq --no-p --no-g --chmod=Fo+r,Do+rx -e 'ssh -o "StrictHostKeyChecking no" -i /root/sshkeys/log_pull_user' \
-f '+ */' -f '+ **access*gz' -f "- *" \
logpull@$HOSTNAME:/var/log/httpd/ /data/stats/logs/$HOSTNAME/
rm -f $LOCKFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment