I'm trying to set up two separate cron jobs that access the same static file. One of the jobs runs every minute, aggregating new data that has arrived into the file. The second job runs every 30 minutes, parsing the aggregated data and truncating the file to reset it for the next 30 minutes.

Obviously there's a potential here for deadlock every 30 minutes. Is there any way to write the cron job for the first task so that it only executes every minute for 29 minutes (short of listing out every minute 1-60, excluding 30 and 60), then starts again on minute 31? Thanks!

**Edit**

By request, I'm using PHP in order to perform these operations (since there is some significant use of data structures involved). I have implemented the use of PHP's `flock` function, and while the [function's documentation](http://us.php.net/flock) specifies that the call blocks until 1) the lock is obtained, or 2) the `LOCK_NB` option is specified, I was confused by the fact that the following example seems to imply it's possible to not obtain the lock, even with a blocking call.

Unless this is due to some other issue (permissions, OS interrupts, etc)? This issue of blocking until obtaining a lock was really the motivation for my question, to see if there was another way to avoid locking files entirely, thereby mitigating the risk of a non-blocking lock attempt fail and the script halt.