Re: Re: skinning a cat
| From: | Jochem Maas | Date: | Mon, 01 Sep 2008 08:11:33 +0000 |
| Subject: | Re: Re: skinning a cat | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279197@lists.php.net to get a copy of this message | ||
Per Jessen schreef:
Robert Cummings wrote:either way, I've just learn't something new as far as shellscripting goes :-) apart from the xargs command ... that still does my head in (don't worry I'll look it up ... for the umpteenth time).[snip code]got an example? my cat skinning skills need to be improved, the cat won't like it but screw the cat, right?#!/bin/sh while true doI accomplish the same with cron scripts by using locks with expiry.<yourscript> sleep 300doneI 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 )wouldn't creating a dir be better here? (with regard to atomicity)
/Per Jessen, Zürich