Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with process kill script

Status
Not open for further replies.

fathead

IS-IT--Management
Apr 13, 2002
154
0
0
I need a script that will kill a process when a user logs in. This is the process that runs when they are running their software:

term2 25576 25557 0 Jan-30 ttya02 00:00:38 /u/dlcrt/bin/_progres lpgas -e 63 -p MAIN.P -o lpr -s -l 175

I want to kill this process if they login a second time. Users are closing the terminal emulator window before logging out causing licensing issues.

I am using the script below at another location, but I did not write it. I tried using this as a template but nothing worked.

Any help would be appreciated


whoami|tee usrfile
usr=`cat usrfile`

ps -no-heading -U $usr|grep rts|cut -c 1-5|tee testfile

num=`cat testfile`

kill -9 $num

# End of the runkillcp script
# Start CP now

cd /u/syn
./syn

 
It may be that the process left behind becomes a zombie, in which case the kill probably wouldn't have any effect. Not sure whether there are any other avenues except rebooting to kill these.

 
You're using this scirpt at another location. Is it working there? Did you make a copy to this location?
If so, it might be that syn isn't an executable anymore.
When you use ./ the file has to have the +x permissions.
If it hasn't, you can set them by:
#chmod +x syn


 
Your "script at another location" is not for SCO Unix (at least not for OpenServer).
What about this ?
num=`ps -fu $LOGNAME | awk '/[_]progress/{print $2}'`
[ "$num" ] && kill -9 $num
# start the app


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top