12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/bin/bash
- if [[ "$1" = "" ]];then
- apachelog more;
- else
- site=$1;
- shift;
- if [[ "$1" == "" ]];then
- t=$site;
- site="";
- path="/var/log/apache2/error.log";
- else
- t=$1;
- shift;
- path="/var/log/apache2/$site.error.log";
- fi;
- case "$t" in
- search)
- cat $path | grep "$@";
- ;;
- ignore)
- cat $path | grep -v "$@";
- ;;
- tail)
- if [[ "$@" == "" ]];then
- tail -f $path;
- else
- tail --lines="$@" $path;
- fi;
- ;;
- more)
- more $path;
- ;;
- flush)
- echo "" > $path;
- ;;
- sites)
- ls /var/log/apache2/*.error.log | awk '{print gensub(/\.error\.log$/, "", "g", gensub(/^.*\//, "","g"))}';
- ;;
- *)
- echo "Usage: $0 <site> [{search|ignore|tail|more|flush|sites} <params>]";
- exit 1;
- esac;
- fi;
|