Sometimes Simple Is Better

Python is a great language and can solve a variety of problems. But sometimes, a plain shell script will do just fine.

#!/bin/bash
#
# drop_csm_users.sh -- grabs anyone running fglgo csm and kills their
# process. This must run under root's user, no matter who calls it.
# This has to run and allow sqlexecd to continue running. It's a little
# bit different than drop_ics_users.pl
#
# Change History:
#

cat /dev/null > /tmp/csm_users

ps -ef | grep -v 'grep' | grep 'fglgo csm' > /tmp/csm_processes

RC1=$?

if [ $RC1 -eq 0 ]; then
    while read line
    do
        echo -e "$linen"
        ccmd=`echo $line  | cut -b 8-14`
        kpl="kill -9 $ccmd"
        echo "Forking this kill command $kpl"
        $kpl
    done < /tmp/csm_processes
fi
Advertisements

Leave a comment

Filed under Programming, python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s