Re: [PHP] only one at atime



We have a virtual stock exchange site (for learning purpose) we put
all the bids and offers in a table and every minute we run the php
script to make the exchange

but my customer want to make it less than 1 minute

On 10/31/06, Ed Lazor <edlazor@xxxxxxxxx> wrote:

On Oct 30, 2006, at 10:14 AM, Ahmad Al-Twaijiry wrote:

> Hi everyone,
>
> I create a php script that will run every minute (by cronjob) and
> update some database tables (php 5, database mysql 5, tables type
> innodb)
>
> the problem is that I want this script to run only one at atime (only
> one process from this script can run )
>
> for example, if the cronjob start the script and the script takes more
> than one minute, then after this one minute the cronjob start another
> process from this script, it should exit once it find there is an old
> process of it running)
>
> what I do now is that when the script start it will check for a tmp
> file (/tmp/script.pid) and if it fine it it will exit.
> if the file (/tmp/script.pid) is not exists, it will create it and
> start doing the database update
> and when the script finish it will remove the file
>
>
> any better idea ?

It sounds like how I'd approach it, but it depends somewhat on the
type of updates your script is performing and how busy your website
is. Plus, I'm curious, what kind of updates are needing to occur
every 30 seconds? And, if your scripts are at risk of running for
more than 30 seconds, does this mean that the volume of data you're
working with end up building upon itself? Just wondering, because it
sounds like you could end up hammering your database server.

-Ed


.



Relevant Pages

  • Re: [PHP] PHP console script vs C/C++/C#
    ... My script is taking a longer time to execute than I want. ... I prefer to write in PHP because that is what I know best. ... This is why I am thinking about rewriting my whole script in a C language. ... Perhaps there are different methods I could be using to speed up execution. ...
    (php.general)
  • Re: How to Add a Feeback Form
    ... I saw nothing in that script that indicates where the form is e-mailed to so ... Greg Maxey/Word MVP ... PHP or not. ... have the support available yet. ...
    (microsoft.public.frontpage.programming)
  • How best to show PHP source? (was: One page, multiple submit buttons)
    ... script to add to the top of a PHP script to enable showing its ... Maybe anybody submitting their own PHP code for critique here ... Anything posted to a newsgroup is a "snapshot" of what the ... there ought to be a FAQ for this ...
    (comp.lang.php)
  • Re: [PHP] PHP console script vs C/C++/C#
    ... My script is taking a longer time to execute than I want. ... I prefer to write in PHP because that is what I know best. ... thinking about rewriting my whole script in a C language. ... execution of the code. ...
    (php.general)
  • Email form script
    ... I have a web form that posts to a .php ... who cannot run .php on their server. ... Or does anyone have a .asp script that will ... Thank you for choosing FormToEmail by FormToEmail.com ...
    (microsoft.public.scripting.jscript)