Re: [PHP] only one at atime



BTW:

we use PDO functions to connect to the database and we also made the
tables innodb type

so if we use $dbh->beginTransaction();

is it will be safe to run the script more than one in the same time ?


On 10/31/06, Ahmad Al-Twaijiry <ahmadt@xxxxxxxxx> wrote:
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
>
>



--

Ahmad
http://www.v-tadawul.com
.



Relevant Pages

  • [NEWS] IBM Informix Web DataBlade Local Root by Design
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... that ease development of "intelligent", interactive, Web-enabled database ... person who has access to change the Perl script. ...
    (Securiteam)
  • RE: Need some MySQL query help...
    ... attempting to run the script: ... passed to the database. ... passwd entry to the current database entry. ...
    (perl.dbi.users)
  • Re: Function that returns date of file.
    ... string after the date/time when it is used by itself. ... Is that your entire script? ... I make an IF statement that required the 'equals equals'. ... designed database your job will be all that much harder. ...
    (alt.php)
  • Re: script dies yet there are no errors in error log
    ... It might be better to ensure the case of the entries in the database, ... This kind of error usually is caused by a CGI or PHP failing to ... input could not be more simple, just a bunch of UPC codes, one per line: ... Given 15 such numbers, the script does fine. ...
    (comp.lang.php)
  • Re: Cannot Open SQL Server Table in Access.ADP File.
    ... I dont think that SQL Server will take 'veiw dependencies' into effect; ... Generate Script Wizard did not work on my original database, ... After fixing some of my tables and a few stored procedures and views, ...
    (microsoft.public.access.adp.sqlserver)