Skip to content

Instantly share code, notes, and snippets.

@anon5r
Created August 23, 2012 10:42
Show Gist options
  • Save anon5r/3435391 to your computer and use it in GitHub Desktop.
Save anon5r/3435391 to your computer and use it in GitHub Desktop.
Show latest log for nginx (access.log or error.log)
#!/bin/sh
#
# args[1] : hostname
# args[2] : access | error
# args[3] : date[yyyy/mm]
#
filehost="*"
filetype="access"
filedate="current"
if [ $# -gt 0 ]; then
if [ "$1" != "" ]; then
filehost=$1
fi
if [ "$2" != "" ]; then
filetype=$2
fi
if [ "$3" != "" ]; then
filedate=$3
fi
fi
filename="${filehost}-${filetype}.log";
tail -s 0.1 -f /home/logs/nginx/$filedate/$filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment