Friday, June 29, 2012

% make FF



% cat Makefile


FOLLOWERS?=
ME?=Tonejito
SIGNATURE?="= ^ . ^ ="


FF:
if [ "${FOLLOWERS}" ] ; \
then  \
 for FOLLOWER in ${FOLLOWERS} ;  \
 do  \
   echo "FF @$$FOLLOWER" ;  \
 done ;  \
else  \
 echo "FF @${ME}" ;  \
fi ;
echo ${SIGNATURE} ;
--


% make -s
FF @Tonejito
= ^ . ^ =


% make -s FF FOLLOWERS="alpha beta gamma"
FF @alpha
FF @beta
FF @gamma
= ^ . ^ =


--


crontab -e



# m h  dom mon dow   command
  0 12  *   *   5    make FF


--
= ^ . ^ =

Tuesday, June 19, 2012

Kill annoying processes that match a pattern

So, there was a bunch of annoying processes named wit a pattern and I wanted to kill all of them

Here is the script (I know this can be done in a much cleaner way in awk, but I like this way)


#!/bin/sh
P="master(-worker)?"

PS=/bin/ps
SED=/bin/sed
KILL=/bin/kill
GREP=/bin/grep
CUT=/usr/bin/cut

$KILL `$PS ax | $GREP -E $P | $GREP -v grep | $SED -e 's/^\ \+//g' | $CUT -d ' ' -f 1 | $GREP -E '^[[:digit:]]+'`

--
  = ^ . ^ =