Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a Postgresql procedure through Windows Task Scheduler

How can I execute a procedure like SELECT my_proc() inside my POSTGRESQL database using Windows Task Scheduler? Is it possible to make a script to call my procedure every 5 minutes? If it's possible I need one.

I can't use pgAgent in my environment, sorry guys!

Any tips?

like image 947
ricardocaldeira Avatar asked Jul 06 '26 16:07

ricardocaldeira


1 Answers

Use Task Scheduler to run psql on the desired schedule, with a command like:

psql -U username -d databasename -w -c 'SELECT my_procedure()'

and put the password in your .pgpass file, or set a PGPASS environment variable in the task.

You don't need any kind of script unless you want to do command specific error handling.

like image 163
Craig Ringer Avatar answered Jul 08 '26 05:07

Craig Ringer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!