Re: [background process] not once, but twice
| From: | pete M | Date: | Wed, 28 Apr 2004 11:05:47 +0000 |
| Subject: | Re: [background process] not once, but twice | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184858@lists.php.net to get a copy of this message | ||
Don't know how to answer your question but I had a similar problem recently and this is how I tackled it; my problem was with multiple users clicking the same time.
1) set up a crontab on the shell to execute a script every 5 mins
2) script checked database to see if another process was running and if so exited
3) If no other process was running then it queried the database and sent out the emails
pete
Jose De Zarate wrote:
hello up there. I have a somehow complex question. I've read a lot of mailing list archives on multiples websites, and 'I still haven't found what I'm looking for'. The thing is this. I have a sending-bulleting page in which you choose the kind of users you want to send the bulletin to (maybe a thousand), and then you just click on 'send bulletin'. at that point, php should make some checking that has to be done user by user, and then put the emails in a database, in order to send them later. It can spend a lot of time doing all the checking, and so I made the checking script a php script that would be executed from the command line, and I call it from the web application with a '&' and a '>test', so I put it on the background. The code would be: exec('php -f sendBulletin.php > temp &'); it -more or less- work fine. Whe I click 'send bulletin', the process start in the background and I get my page back without having to wait for it to finish. But if I try to do it again, and the previous process has not finished yet, then php will hang untill that process finishes. I have absolutely no idea of why this weird behavior happens. I just can't figure out what's going on!! Can any of you give me a clue??????? txs. a lot. Jose de Zarate La Havana, Cuba.