stupid but semi useful script

Categories: Script

so i was doing some misc work on one of my machines the other day and as i was working i kept having this service restarting even though i kind of needed it on but at the time i needed it off.

so i wrote this stupid little find, message and kill script to cron out the kills.

this script assumes you have a valid mailer installed (i use mailx):


# this case finds and messages admin up top
if [ -f ${TEMP_FILE} ]; then
        rm -rfd ${TEMP_FILE} && touch ${TEMP_FILE}

# change <replace me> to process name you need killed off
${TOP} -b -n 1 | egrep <replace me> ${TEMP_FILE}

if [ -s ${TEMP_FILE} ]; then
        DEAD_PID=`cat ${TEMP_FILE} | awk '{print $1}'`
        printf "pid ${DEAD_PID} being killed." | mailx -s "pid being killed" $ADMIN
        kill -9 ${DEAD_PID}

it serves a purpose…..sort of


    Leave a Reply

    Your email address will not be published. Required fields are marked *