Run function in "background"
<h2>Objects:</h2>

<ul>
<li>Object Sale</li>
<li>n Object User will participate on Object Sale</li>
<li>Each User can create one Object Agent</li>
<li>Each Agent will generate n Object Licitation (from time to time and with some conditions) for the object Sale</li>
</ul>

<h2>Goal:</h2>

<p>Create a function that when a Sale has only 5 seconds left to end, will check all the Agents that there are for this Sale and post a licitation from the Agent that hasn't made a licitation on this sale the longest</p>

<p>This is something that needs to be continuously running since this agents would be in charge to replace users on posting licitations allowing them to be away during auctions.</p>

<h2>My question</h2>

<p><strong>Updated (My question wasn't clear enough):</strong></p>

<p>At index page of the sales I have a script with javascript that calculates the time left on a sale, so I can know when a sale should call the function to check for agents and place their bids, but my newbie question is: if I make a call for the function at this page, will this only work if the user has the page open? Or if he closes the function won't be called anymore? Because I need this to still work even the user closes webpage.
<strong><em>DaMacc already answered that this doesn't work</em></strong></p>

<p><strong>Updated (05/01/2010)</strong></p>

<p>I've already created this function. The function will find all the sales that have 5 seconds left to end, then it will search all the agents and then place a bid from the agent that hasn't made a licitation on the selected sale the longest. Now i need this function to be called every second. I was going to use <em>cron</em> but <strong><em>cron has 1-minute boundaries</em></strong>. And I need this function to run on the server and not depend on the user that owns the agent.</p>

<p>Any suggestions?</p>

<p>PS: there are some auctions websites that have this kind of bidagents i'm trying to do, I could reffer one to use as example... But i'm not sure i'm allowed to do that here... :S</p>

<p>Thanks.</p>
