Re: starting shell script on server: defer acces when running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, June 6, 2006 3:10 pm, Roel Dillen wrote:
> I have a shell script I want to run which generates an html page after
> it
> runs some tests on the software I am writing.
>
> I call the script with exec(?);
>
> The tests take more than 2 minutes to complete.
>
> If I try to run more than one test at the same time: trouble.
>
>
>
> I want to solve this by checking somehow whether the tests are
> running.
>
> If so, then the php code just waits until the running test are
> complete,
> referring the second user to the same results page as the first.

<?php
  if (@file_exists("/var/shared/locks/" . __FILE__)){
    exit; //already running
  }
  touch("/var/shared/locks/" . __FILE__);
  //rest of script here
  unlink("/var/shared/locks/" . __FILE__);
?>

You can also incorporate http://php.net/filemtime to automatically
remove locks that are older than, say, an hour, so that aborted/killed
scripts don't stay locked up.



-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux