Thread: Newbie question
hi, is it possible to schedule the execution of an sql stored procedure in postgress on linux? thanks Hugo
IMHO cron would be the best for that... > is it possible to schedule the execution of an sql stored procedure in > postgress on linux? -- Vlad
Sure. Just set up psql with a SQL script containing your task using a chron job. The psql utility will accept a command file as a parameter. PostgreSQL has functions rather than stored procedures, but it works out about the same. You could also put a bunch of SQL commands that you want to run in the file that you feed to psql. > -----Original Message----- > From: pgsql-general-owner@postgresql.org [mailto:pgsql-general- > owner@postgresql.org] On Behalf Of Hugo > Sent: Wednesday, May 18, 2005 8:24 AM > To: pgsql-general@postgresql.org > Subject: [GENERAL] Newbie question > > hi, > > is it possible to schedule the execution of an sql stored procedure in > postgress on linux? > > thanks > > Hugo > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend
Dear Hugo, It is possible using cron and psql. Just "man cron" on unix if you're not already familiar with that. The command line you should use is something like: psql [connection options] -f sql_commands_file.sql Also "man psql" for the options you can use... Starting the procedure should be done by something like: SELECT procedure_name(); in the sql commands file given to psql. Alternatively you can do: echo "SELECT procedure_name();" | psql [connection options] but I don't know how well that works with cron... I'm not actually using it... HTH, Csaba. On Wed, 2005-05-18 at 17:23, Hugo wrote: > hi, > > is it possible to schedule the execution of an sql stored procedure in > postgress on linux? > > thanks > > Hugo > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend
Hi Hugo, Yes, it is possible. Just write an outer perl script(in example), which to call this stored procedure. Then put in the cron to call whis perl script. As Far As I Know there isn't other way. Kaloyan Iliev Hugo wrote: >hi, > >is it possible to schedule the execution of an sql stored procedure in >postgress on linux? > >thanks > >Hugo > >---------------------------(end of broadcast)--------------------------- >TIP 8: explain analyze is your friend > > > >
thanks all for your help, I'll try your suggestions regards Hugo 2005/5/18, Kaloyan Iliev Iliev <news1@faith.digsys.bg>: > Hi Hugo, > > Yes, it is possible. Just write an outer perl script(in example), which > to call this stored procedure. Then put in the cron to call whis perl > script. As Far As I Know there isn't other way. > > Kaloyan Iliev > > Hugo wrote: > > >hi, > > > >is it possible to schedule the execution of an sql stored procedure in > >postgress on linux? > > > >thanks > > > >Hugo > > > >---------------------------(end of broadcast)--------------------------- > >TIP 8: explain analyze is your friend > > > > > > > > >
Hugo wrote: > hi, > > is it possible to schedule the execution of an sql stored procedure in > postgress on linux? > > thanks > > Hugo cron job: eg. Sat 2:30am 30 2 * * Sat psql -d dbname -c "select your_func()" -- _______________________________ This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. _______________________________
Kaloyan Iliev Iliev wrote: > Hi Hugo, > > Yes, it is possible. Just write an outer perl script(in example), which > to call this stored procedure. Then put in the cron to call whis perl > script. As Far As I Know there isn't other way. Depending on whether you want to schedule a procedure on a regular basis or not. You could us 'at' to schedule a one time procedure execution. -- Until later, Geoffrey