RE: [CentOS] Any one have a good example...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tue, 2006-08-29 at 15:25 -0400, mike.redan@xxxxxxx wrote:
> Something like this works alright:
> 
> 
> # Check if process is running already
> SCRIPT_NAME=do_stuff
> pidfile=/tmp/$SCRIPT_NAME.pid
> 
> 
> if [ -f $pidfile ]; then
>    runpid=`cat $pidfile`
>    if ps -p $runpid; then
>       echo "$SCRIPT_NAME is already running ... stopping"
>       exit 1
>    else
>       echo "$SCRIPT_NAME pid found but process dead, cleaning up and
> starting ..."
>       rm -f $pidfile
>    fi
> else
>    echo "No $SCRIPT_NAME Process Detected ... starting"
> fi
> 
> echo $$ > $pidfile
> 

Maybe I am being dense here ... BUT ...

Doesn't the "echo $$" only happen AFTER the else process is finished ???

if you make the "else" process be the rsync script, then it will not
create $pidfile until after the rsync is done ... which does not help
you.

if you leave the else process as is and kick off the rsync after the
echo $$ then it is not the same PID that you wrote to the $pidfile and
you will start more than one rsync process ... as the PID that you wrote
to $pidfile as the echo process ... that already finished ... or I am
mistaken?

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux