Re: skinning a cat (was: Individual bulk e-mails - performance question)
| From: | Per Jessen | Date: | Mon, 01 Sep 2008 07:44:24 +0000 |
| Subject: | Re: skinning a cat (was: Individual bulk e-mails - performance question) | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279196@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
>> >> #!/bin/sh
>> >> while true
>> >> do
>> >> <yourscript>
>> >> sleep 300
>> >> done
>> >
>> > I accomplish the same with cron scripts by using locks with expiry..
>>
>> got an example? my cat skinning skills need to be improved, the cat
>> won't like it but screw the cat, right?
>
[snip code]
> I implemented my own lock class which uses directory creation and the
> return value to determine if the lock was successful. Unlike file
> creation (or so I read several years ago) directory creation is atomic
> and works across NFS. As an added benefit, I'm able to store lock
> related data into the lock directory as files.
I'm probably old fashioned, but to me all that stuff is way overkill. I
also tend to think that synchronizing scripts is a job for the shell,
not PHP.
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
)
/Per Jessen, Zürich