Please help: Prevent Multiple Instances

This is a discussion on Please help: Prevent Multiple Instances within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi All, How can I prevent a script from running when a previous instance of the script had already been ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-07-2004
Jerry
 
Posts: n/a
Default Please help: Prevent Multiple Instances

Hi All,

How can I prevent a script from running when a previous instance of
the script had already been triggered and the script is running in the
background already?
So, even when a script is startet several times (eg. by several
website visitors) I want only one script-instance running on the
server. Subsequent instances should be exited (or prevented) right
away to keep the server load as low as possible.

However, when no instance of the script is currently running (eg.
after a server shut-down), triggering the script should make it run -
but again: only one instance should be running at all times. Further
script calls, as said above, should then not be allowed.

Any ideas?
Thanks a ton if somebady can help me.
Jerry

Reply With Quote
  #2 (permalink)  
Old 06-07-2004
Manuel Lemos
 
Posts: n/a
Default Re: Please help: Prevent Multiple Instances

Hello,

On 06/07/2004 05:09 AM, Jerry wrote:
> How can I prevent a script from running when a previous instance of
> the script had already been triggered and the script is running in the
> background already?
> So, even when a script is startet several times (eg. by several
> website visitors) I want only one script-instance running on the
> server. Subsequent instances should be exited (or prevented) right
> away to keep the server load as low as possible.
>
> However, when no instance of the script is currently running (eg.
> after a server shut-down), triggering the script should make it run -
> but again: only one instance should be running at all times. Further
> script calls, as said above, should then not be allowed.


I use flock() to obtain a lock in a specified file to be associated with
the task. The first script to obtain the lock will prevent others to
grab it.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:15 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0