parse apache access log entries to find top user agents, top urls and top IPs

This script will allow you to see the top user agents, urls, IPs for your log files:

 

Script name: ls-httpd

#!/bin/bash # Usage # ls-httpd type count # Eg: # ls-httpd url 1000 # will find top URLs in the last 1000 access log entries # ls-httpd ip 1000 # will find top IPs . . . → Read More: parse apache access log entries to find top user agents, top urls and top IPs

kill liferay script

Here’s a bash kill liferay script!

This should kill any running liferay or liferay social office on a linux system.

Open up your favorite editor and paste this in

#!/bin/bash # #Script name: kill_liferay.sh # #Purpose: To kill any running instance of liferay on a linux system # #Usage: ./kill_liferay.sh # for pid in `ps . . . → Read More: kill liferay script

gzip log files older than one day

To Gzip files older than one day place this in a cronjob: TODAY=`date +”%Y-%m-%d”`

for logfile in /var/log/tomcat6/*.log; do # grab the %Y-%m-%d out of the name DTS=${logfile:(-14):10} if [ $DTS != $TODAY ]; then # compress in place gzip $logfile fi done

kill orphaned httpd processes

to kill orphaned httpd processes create a script called killhttpd.sh with the following code

#!/bin/bash for pid in `ps -C httpd|sed -e ‘s/^\ \+//g’ | grep httpd|awk ‘{print $1}’` do kill $pid done

bash diff alternative

How to setup a bash diff alternative nano -w /usr/bin/diff2

Copy and paste the below in to /usr/bin/diff2

#!/bin/bash # # name: diff2.sh # usage: ./diff2.sh file1 file2 # To make available to whole system copy to /usr/local/bin # and rename to diff2 # colorize diff output for ANSI terminals # based on “diff2html” # . . . → Read More: bash diff alternative