Tuesday, October 13, 2009

[ Linux ] x_hk.sh

This script came via the neccesity to abolish services that would result in a reboot/cpanel/panels that inject restart commands onto vps's. As you see it could run alot everyday if something was making it run every 5 minutes like scron.

## x_hk.sh (x-hunter-kill script) ##

#!/bin/bash
# Killer script
# x_hk.sh - includes date.

if date | grep "1:1" >/dev/null;
then
{
echo "### Running the [HK] process on this cycle ###"
echo " "
echo "## clearing the crontab ##"
crontab -r
echo "## trying to kill: httpd ##"
pgrep httpd | xargs -r kill -9
echo "## trying to kill: apache2 ##"
pgrep apache2 | xargs -r kill -9
echo "## trying to kill: xinetd ##"
pgrep xinetd | xargs -r kill -9
echo "## trying to kill: named ##"
pgrep named | xargs -r kill -9
}
else
{
echo "### Not running the [HK] process on this cycle ###"
echo "Current Time: `date`"
echo " "
}
fi

No comments: