Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top