Thread: HOWTO : plpgsql stored function spawn cron job that will run other stored functions
HOWTO : plpgsql stored function spawn cron job that will run other stored functions
From
"Robert M. Bernabe"
Date:
Hi, Many thanks in advance. Any advice and or suggestion for command and/or methods to have a plpgsql stored function create a process / job that will run other stored functions. I've been doing the research but so far no luck. :( Regards I'm protected by SpamBrave http://www.spambrave.com/
Re: HOWTO : plpgsql stored function spawn cron job that will run other stored functions
From
"Obe, Regina"
Date:
Not quite clear what you are asking for. Does PgAgent fit your needs http://www.pgadmin.org/docs/1.8/pgagent.html ? If you needed jobs dynamically created for some reason I think all you would need to do is stuff the appropriate records in the PgAgent related tables. Although I'm not quite sure if you are looking for a simple scheduling agent which is what PgAgent is or for something more advanced or if you have already ruled it out for some other reason. Hope that helps, Regina -----Original Message----- From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Robert M. Bernabe Sent: Thursday, December 20, 2007 5:52 PM To: pgsql-novice@postgresql.org Subject: [NOVICE] HOWTO : plpgsql stored function spawn cron job that will run other stored functions Hi, Many thanks in advance. Any advice and or suggestion for command and/or methods to have a plpgsql stored function create a process / job that will run other stored functions. I've been doing the research but so far no luck. :( Regards I'm protected by SpamBrave http://www.spambrave.com/ ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org ----------------------------------------- The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.
Re: HOWTO : plpgsql stored function spawn cron job that will run other stored functions
From
"Robert M. Bernabe"
Date:
Thanks for the reply. PGAgent is one option I've found but I was hoping somebody can suggest another way to do this that would just use plpgsql and maybe cron. Another method perhaps that is not dependent PGAgent... Basically the system is running off another DB right now and it basically generates processed data in the form of text files. A web interface accepts options and throws the options as parameters to a generate stored function (let's call it 'generate sf') The generate sf will process an option and determine how many times it will call the report stored function and passing on the approriate parameters per iteration (this could be in the 10s, 100s or 1000s). Since the entire processing can take a long time, the generate sf creates a process/job that handles the report stored functions so that the generate sf can return a status to the web page. Another web page enables the user to view the status of the job. I need to find a way to do this in PostgreSQL. Basically a stored function that would spawn a process and return to the web page a status. The spawned process will be responsible in creating the report files through the report stored function. Hope that is clear. Again, many thanks in advance. ----- Original Message ----- From: "Obe, Regina" <robe.dnd@cityofboston.gov> To: "Robert M. Bernabe" <rbernabe@sandmansystems.com>; <pgsql-novice@postgresql.org> Sent: Friday, December 21, 2007 8:07 PM Subject: RE: [NOVICE] HOWTO : plpgsql stored function spawn cron job that will run other stored functions Not quite clear what you are asking for. Does PgAgent fit your needs http://www.pgadmin.org/docs/1.8/pgagent.html ? If you needed jobs dynamically created for some reason I think all you would need to do is stuff the appropriate records in the PgAgent related tables. Although I'm not quite sure if you are looking for a simple scheduling agent which is what PgAgent is or for something more advanced or if you have already ruled it out for some other reason. Hope that helps, Regina -----Original Message----- From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Robert M. Bernabe Sent: Thursday, December 20, 2007 5:52 PM To: pgsql-novice@postgresql.org Subject: [NOVICE] HOWTO : plpgsql stored function spawn cron job that will run other stored functions Hi, Many thanks in advance. Any advice and or suggestion for command and/or methods to have a plpgsql stored function create a process / job that will run other stored functions. I've been doing the research but so far no luck. :( Regards I'm protected by SpamBrave http://www.spambrave.com/ ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org ----------------------------------------- The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.
Re: HOWTO : plpgsql stored function spawn cron job that will run other stored functions
From
John DeSoi
Date:
On Dec 21, 2007, at 7:43 AM, Robert M. Bernabe wrote: > Thanks for the reply. PGAgent is one option I've found but I was > hoping somebody can suggest another way to do this that would just > use plpgsql and maybe cron. Another method perhaps that is not > dependent PGAgent... You can't do this in plpgsql alone. There is no built-in facility to make something run at some interval. If you use cron, all you need to do is have it call your function from a shell script. Something like: psql -d database -U user -c "select my_store_function()" John DeSoi, Ph.D.
Re: HOWTO : plpgsql stored function spawn cron job that will run other stored functions
From
"Robert M. Bernabe"
Date:
Again Thanks. Would you know of any documentation that details how to programmatically control pgagent? Also something that details the tables it uses plus maybe scripting and interface? Thanks. ----- Original Message ----- From: "Obe, Regina" <robe.dnd@cityofboston.gov> To: "Robert M. Bernabe" <rbernabe@sandmansystems.com>; <pgsql-novice@postgresql.org> Sent: Friday, December 21, 2007 8:07 PM Subject: RE: [NOVICE] HOWTO : plpgsql stored function spawn cron job that will run other stored functions Not quite clear what you are asking for. Does PgAgent fit your needs http://www.pgadmin.org/docs/1.8/pgagent.html ? If you needed jobs dynamically created for some reason I think all you would need to do is stuff the appropriate records in the PgAgent related tables. Although I'm not quite sure if you are looking for a simple scheduling agent which is what PgAgent is or for something more advanced or if you have already ruled it out for some other reason. Hope that helps, Regina I'm protected by SpamBrave http://www.spambrave.com/
Re: HOWTO : plpgsql stored function spawn cron job that will run other stored functions
From
"Obe, Regina"
Date:
Well pgagent I think pretty much uses the tables it creates in the PgAgent catalog of postgres. From then it pretty much behaves like crontab. So to programmatically control it, I would guess all you would need to do is manually stuff records in the pga_job, pga_jobstep, pga_schedule tables and delete them and so forth. I think that is all pgAdmin is really doing when you use the job edit feature. I don't think there is any specific documentation on it, but the tables look pretty straight forward and there aren't that many of them. The best way to see how to structure the jobs would be 1) Create a Job with PgAdmin III 2) Before you click okay - switch to the SQL tab and see what kind of SQL it is generating to build the job. Hope that helps, Regina -----Original Message----- From: Robert M. Bernabe [mailto:rbernabe@sandmansystems.com] Sent: Friday, December 21, 2007 6:42 PM To: Obe, Regina; pgsql-novice@postgresql.org Subject: Re: [NOVICE] HOWTO : plpgsql stored function spawn cron job that will run other stored functions Again Thanks. Would you know of any documentation that details how to programmatically control pgagent? Also something that details the tables it uses plus maybe scripting and interface? Thanks. ----- Original Message ----- From: "Obe, Regina" <robe.dnd@cityofboston.gov> To: "Robert M. Bernabe" <rbernabe@sandmansystems.com>; <pgsql-novice@postgresql.org> Sent: Friday, December 21, 2007 8:07 PM Subject: RE: [NOVICE] HOWTO : plpgsql stored function spawn cron job that will run other stored functions Not quite clear what you are asking for. Does PgAgent fit your needs http://www.pgadmin.org/docs/1.8/pgagent.html ? If you needed jobs dynamically created for some reason I think all you would need to do is stuff the appropriate records in the PgAgent related tables. Although I'm not quite sure if you are looking for a simple scheduling agent which is what PgAgent is or for something more advanced or if you have already ruled it out for some other reason. Hope that helps, Regina I'm protected by SpamBrave http://www.spambrave.com/ ----------------------------------------- The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.