X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 560919DD447 for ; Tue, 21 Mar 2006 09:02:29 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66615-03 for ; Tue, 21 Mar 2006 09:02:32 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from vsmtp2.tin.it (vsmtp2.tin.it [212.216.176.222]) by postgresql.org (Postfix) with ESMTP id 2498F9DD369 for ; Tue, 21 Mar 2006 09:02:26 -0400 (AST) Received: from [192.168.2.5] (87.5.119.156) by vsmtp2.tin.it (7.2.072.1) (authenticated as apbertolini@virgilio.it) id 44057FFC0119A9D5 for pgsql-sql@postgresql.org; Tue, 21 Mar 2006 14:03:23 +0100 Message-ID: <441FF966.2020202@computer.org> Date: Tue, 21 Mar 2006 14:02:30 +0100 From: Alexis Paul Bertolini User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Job queue, how would you implement this? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] X-Spam-Score: 0.479 X-Spam-Level: X-Archive-Number: 200603/326 X-Sequence-Number: 24672 Dear all, I have implemented a job queue table where various apps can add jobs to the queue and other daemons then execute them. A basic producer-consumer pattern. Each tuple in the queue has the basic info such as job to be done, when it should be done, who should do it, a flag marking it completed. The consumer thus selects from the queue all jobs who scheduled in the past (<=CURRENT_TIMESTAMP) and are not flagged. Then flags them upon succesfull completion. I now wish to implement repeating scheduled jobs, like "every 5 minutes", "every morning at 7.00am" and so on. How could I do this? Any suggestions are welcome and if necessary I can provide you with more info. Thanks Alex.