Posts Tagged commadline

Sendmail mailq management.

Had to clean out a sendmail mail queue that was huge today. Found a couple of geat ways to locate mail that can be removed from the mail queue using awk and xargs.

Delete files from mqueue by looking for keywords in the queue file:

grep 'error' qf* | grep -v '<your domain>' | awk -F: '{print $1}' | awk -Ff '{print $2}' | xargs -I file rm -f dffile qffile

Delete mail from mail queue that had no sender address:

mailq | grep '<>' | awk '{print $1}' | xargs -I file rm -f qffile dffile

I was also exchanging the xargs part of the command with wc -l to count how many of the problem mails are in the mail queue.

Tags: , , , , , , , ,

Installing yum on Centos-5 VPS

I have been going the way of installing all of the packages on Centos VPS using wget to get the packages. Here is a one line command to install yum:

vzpkg install <CTID> -p yum

Tags: , , ,

Shell Commands for HTTP access log

I had to do some anayalsis of a clients site and verify if it was actually as popular as the data usage and web statistics said it was. Bellow are some of the shell commands that I have used to analyze the access log on the server the site was hosted on:

Unique IP’s and amount of entries in access_log:
======================================
cat <path to log file> | awk ‘{print $1}’ | sort -n | uniq -c

Amount of unique IP’s:
===================
cat <path to log file> | awk ‘{print $1}’ | sort -n | uniq -c | wc -l

Amount of Bytes of data from files logged.
=================================
cat <path to log file> | awk ‘{sum+=$10}END{print sum}’

Unique files and the amount of times accessed
====================================
cat <path to log file> | awk ‘{print $7}’ | sort | uniq -c | sort -n -r

Unique files and there size in bytes
============================
cat <path to log file> | awk ‘{print $10, $7}’ | sort -n -r

Tags: , , , , , ,

Find Dell Service Tag from the Linux console

I deployed a Dell server down at the datacentre only to realise that I had not taken down the Service Tag number. A quick look on google and I found a simple way to find your service tag via SSH

dmidecode | grep "Serial Number"

Dmidecode shows heaps of information that I have yet to have a closer look at. The command is located in /usr/sbin

Tags: , ,