2015-05-12 11:27 GMT+02:00 hubert depesz lubaczewski <dep...@depesz.com>:

> On Tue, May 12, 2015 at 09:25:50AM +0200, Pavel Stehule wrote:
> > create type scheduled_time as (second int[], minute int[], hour int[],
> dow
> > int[], month int[]);
> >  (,"{1,10,20,30,40,50}",,,) .. run every 10 minutes.
> >  (,"{5}",,,) .. run once per hour
> > Comments, notices?
>
> First, please note that I'm definitely not a hacker, just a user.
>
> One comment that I'd like to make, is that since we're at planning
> phase, I think it would be great to add capability to limit number of
> executions of given command.
> This would allow running things like "at" in unix - run once, at given
> time, and that's it.
>

I would not to store state on this level - so "at" should be implemented on
higher level. There is very high number of possible strategies, what can be
done with failed tasks - and I would not to open this topic. I believe with
proposed scheduler, anybody can simply implement what need in PLpgSQL with
dynamic SQL. But on second hand "run once" can be implemented with proposed
API too.


pg_create_scheduled_command('delete obsolete data', '(,,"{1}","{1}",)',
$$DO $_$
  BEGIN
    DELETE FROM data WHERE inserted < current_timestamp - interval '1month';
    PERFORM pg_update_scheduled_command(scheduled_command_oid(),
max_workers => 0);
  END $_$
$$);

Regards

Pavel




> Best regards,
>
> depesz
>
> --
> The best thing about modern society is how easy it is to avoid contact
> with it.
>
> http://depesz.com/
>

Reply via email to