By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,656 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Please help: Prevent Multiple Instances

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.