Simple command to “watch” the webserver access log
April 2nd, 2010 | by Sajal Kayan | TweetI am often curious as to what bots are going on my site at any given moment. So much so that I devote one terminal tab to running this script.
save the following as say bot.sh and make it executable :-
-
#!/bin/bash
-
watch "grep $1 /path/to/access.log | tail -15"
note: the number after tail can be adjusted depending on your terminal size…
Run it on the server as :-
-
[user@server ~]# ./bot.sh Googlebot
OR
-
[user@server ~]# ./bot.sh msnbot
OR
-
[user@server ~]# ./bot.sh <suspicious ip address>
and so on….
UPDATE: Better alternative by willwill. Save as bot.sh:-
-
#!/bin/bash
-
watch "tail -f /path/to/access.log | grep $1"
