Nathan wrote: > On 2/17/06, Michael Moore <[EMAIL PROTECTED]> wrote: >> Hello shell script gurus. I'm sure I'm doing this the hard way...so if >> you could shed some light. >> >> I'm trying to write a shell script that will only run if it's not >> running already, and if it is running, kill the other process. ie: >> >> if ( other copy of me already running) >> kill both myself and other copy >> else >> do some stuff >> fi >> >> Michael Moore > > Use a PID file. >
The other option besides a PID file is to use pgrep. You give it a pattern and it returns the PID's of all the running processes that match. I'm pretty sure it only compares process name, but you'd have to double check. The nice thing is that it only gives the PID number, so you don't have to do any text processing to pull it out like you would from ps. -Jared Lundell -------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
