Robert Cummings schreef:
On Mon, 2008-09-01 at 14:34 +0200, Merlin Morgenstern wrote:
Per Jessen schrieb:
Jochem Maas wrote:
lockfile=/var/lock/<xxxx>/file
# clear out a lock older than 60mins
find $lockfile -cmin +60 | xargs rm
test ! -f $lockfile && (
touch $lockfile
<run some php>
rm -f $lockfile
)
wouldn't creating a dir be better here? (with regard to atomicity)
I haven't thought it through, but I don't think it would change
anything.
/Per Jessen, Zürich
Hello everybody,
thank you for the huge amount of replies on my question. I believe I
quite lost a bit track on how to solve the problem hands on. To
summerize, there are aparently two ways of skinning the cat :-)
1. Run a deamon
I admit I have never wrote one, and that seems therefore to be the
harder option for me. Well... perhaps not.
I assume it is simply creating a shell script like Jochem wrote, however
I guess it would just take longer for me to get it running as I have
never done that before.
It was Per who posted that script, I merely asked him for clarification ...
it's actually an easy script to implement ... you just about only have
to change one line (the line that runs your cron script) ... and then have
crom run the shell script as opposed to your script directly.
2. Create a PHP file that holds some lock code which is triggered by
CRON every 5 minutes. Taking the example from Robert.
3. Following idea which I am now actually implementing :-)
- Add all emails into a mysql db with one insert command.
- Run a php script by cron every 5 min that does the following:
- update table, set session_id = x on all entries without session id
- get all entries with that session ID
- send email to those with that session ID
- remove all entries with that session ID
Looks like easies sollution on how to skimm the cat. DB might not be the
most performing sollution, but sufficient considering the hard ware power.
Actually 3 was what I suggested with a lock mechanism to ensure that if
your script run by cron takes longer than 5 minutes that you don't have
two scritps stepping on each others' toes.
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php