Archive for the ‘Script’ Category

Go away or I will replace you with a simple shell script

Saturday, February 18th, 2006

Hey ya unknown coward… you are Killed !!
….go away or I will replace you with a simple shell script…
Yes, I found a simple snip to do that without yelling it out :)

mongoose # ps -aux | grep [usrname] | awk ‘{print $2}’ | sort -g | xargs kill -9

This simple snip kill all the process invoked by the user in an order of last process, die first so the user too.

R-I-P

How much disk space ya left …??

Friday, January 13th, 2006

I gotta something… something wacky this time….

When one of our dear employee asked ” Is there any script to know the disk
usage of the system I am using….”

well….I snip one and it’s working fine…

++ Those who S [ ] I T before GATE, please excUse…

=====================================================

This shell script will help us to monitor the disk usage
If any of the disk partiotion space is more than 95%, all the users who were
logged into the system will get an ALERT message
Add the below line to “crontab -e” to run the program for every minute
*/1 * * * * sh /ya/path/to/diskUsage.sh
YMMV and if ya find any issue; please..try it out by yourself ‘/ ‘
tfeLYpoC

#! /bin/bash

df -h | grep -iv used |grep -iv media | awk ‘{print $6″ ” $5}’ |
while read ROW;
do PERCY=`echo $ROW | cut -d”%” -f1 | awk ‘{print $2}’`
if [ $PERCY -gt 95 ]; then
wall -n “ALERT..! from `hostname`
$ROW of the partition is FULL…! ”
fi
done