script question

GoijI P goijiud at hotmail.com
Thu Jan 6 06:58:00 UTC 2005


can this script terminate a job or program , MyLinuxProgram, that runs on 
NFS server but started from NFS client PCs?.

pkill script:
#!/bin/sh
#usage: pkill MyLinuxProgram
for X in `ps acx | grep -i $1 | awk {'print $1'}`; do
  kill $X;
done



Secondly, can this script logoff all bash NFS client user(s) logged in the 
NFS server?:

#!/bin/ksh
#usage: killuser2 all
#       =============
#
# verify arg1 'all'
if [ "$1" != "all" ]; then echo "killuser2 arg1 must be 'all' "; exit 1; fi
# - redirect ps -f output to a tmp file
ps -e -ocomm -opid -oruser >/tmp/psef
#
# - open the file & read back into variables for easier manipulation
exec 3< /tmp/psef            # open file #3
#
x=0; y=0
while read -u3 comm pid ruser
do if [[ ("$comm" == bash) && ("$ruser" != root) ]]
       then let x=x+1
            kill -9 $pid
            if [[ $? == 0 ]]; then kok=OK; let y=y+1; else kok=NAK; fi
            echo "#$x kill $comm $pid $ruser - $kok"
    fi
done
exec 3<&-                    # close file #3
echo "$x kills attempted, $y killed OK $(date)"
#

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




More information about the Redhat-install-list mailing list