Another useful bash function I have on my servers. It’s a wrapper around tail -F and ccze . It will look for a log file (prepends /var/log/ to the patch if it can’t find it), and pipes it into ccze for colorizing the output. Handy if you find yourself watching logs. I mostly use it for dhcp/tftp/mail where I don’t have a huge amount of traffic (i.e. can watch it in real time) and am expecting an event/log entry.
1
2
3
4
5
6
7
8
9
|
logwatch() {
local logfile=
for path in '' /var/log/; do
if [[ -r "${path}${1}" ]]; then
tail -n50 -F "${path}${1}" | ccze ${2:+--plugin} ${2} --mode ansi --convert-date
return
fi
done
}
|
Usage:
1
2
|
logwatch kern.log
logwatch /var/log/apache2/access.log
|