#!/bin/bashlog_dir="/mezi/sites/apache/logs"# tracking log dirmachine_name=`hostname -s`# get short name of this machineif[ -n "$1"]; thensite_path="/mezi/sites/${1}"# site located in /mezi/sites/$site_nameif[ ! -e "$site_path"]; thenecho"There is no such site on this machine!"exit 1
fi#echo "OK, we got the site. Let's tail tracking log for it."date=`date +%Y_%m_%d`log_file_format="${log_dir}/${1}_${machine_name}_${date}*"#get tracking log file format#echo "$log_file_format"log_target=`ls ${log_file_format} 2>/dev/null | sort -rn | head -1`if[ -n "$log_target"]&&[ -e "$log_target"]; thenecho"The latest log file is $log_target" tail -f "$log_target"elseecho"There is no such log file."fielseecho"No site name provided."fi