<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Also...<br>
<br>
running it from inittab will ensure that even if the process crashes it
will run again next time, unlike if you use a self created lockfile....<br>
<br>
P.<br>
<br>
<br>
Marko A. Jennings wrote:
<blockquote
cite="mid43740.192.168.77.10.1156886627.squirrel@bluegargoyle.com"
type="cite">
<pre wrap="">On Tue, August 29, 2006 5:07 pm, Scott Silva wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Johnny Hughes spake the following on 8/29/2006 1:02 PM:
</pre>
<blockquote type="cite">
<pre wrap="">On Tue, 2006-08-29 at 15:59 -0400, <a class="moz-txt-link-abbreviated" href="mailto:mike.redan@bell.ca">mike.redan@bell.ca</a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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?
The idea of it is to place that bit of code at or near the beginning of
your script, then have the rsync process start after the "echo $$".
That
will put the PID of your script into that file, the rsync process will
be started in the script, and the script would not end until the rsync
one does..so you are fairly safe that two instances of your script will
run at thte same time..
</pre>
</blockquote>
<pre wrap="">OK ... I see.
The rsync process is a second PID ... but the first PID is also still
open until after the script closes.
</pre>
</blockquote>
<pre wrap="">I tried the above, but was able to start multiple copies of the script.
So I will have to see what is not catching the runs.
The lockfile is there, but not stopping another execution of the script.
</pre>
</blockquote>
<pre wrap=""><!---->
I use the lockfile utility. Take a look at its man page, it is well
written. Here is how I use it (Bourne shell):
# try to create the lock and check the outcome
lockfile -r 0 /var/run/myapp.lock 1>/dev/null 2>&1
status=$?
if [ ${status} -ne 0 ] ;then
echo "Another instance already running. Aborting."
exit 1
fi
# body of the script here
# remove the lock at the end of the script
rm -f /var/run/myapp.lock
_______________________________________________
CentOS mailing list
<a class="moz-txt-link-abbreviated" href="mailto:CentOS@centos.org">CentOS@centos.org</a>
<a class="moz-txt-link-freetext" href="http://lists.centos.org/mailman/listinfo/centos">http://lists.centos.org/mailman/listinfo/centos</a>
</pre>
</blockquote>
</body>
<br />--
<br />This message has been scanned for viruses and
<br />dangerous content by the
<a href="http://www.enhancion.net/"><b>Enhancion</b></a> system scanner,
<br />and is believed to be clean.
</html>