Friday, November 9, 2012

How to Schedule PostgreSQL query on Windows

To run one or multip query on Windows at Special time.

I create two files:


select DailyReport();


@echo off
set PGUSER=your_username
set PGPASSWORD=your_password
C:UserAdminPostgreSQL9.1binpsql --host=192.168.XXX.XXX --dbname dbname --port=5432 --file=D:yourquery.sql


Then create schedule job:

schtasks /Create /SC DAILY /ST 00:00:00 /TN Pgsql_DailyJob /RU “NT AUTHORITYSYSTEM” /TR D:PG_JobsPgsql_Daily.bat


  1. I intended to put you a very little remark to say thanks a lot again relating to the fantastic things you've shown on this site. This has been simply unbelievably generous of you giving without restraint all most people would have marketed as an ebook to help make some dough for themselves, mostly considering the fact that you could possibly have tried it in the event you desired. These solutions likewise worked to provide a easy way to be sure that other people have a similar interest much like my personal own to learn way more concerning this problem. I'm sure there are some more fun instances in the future for individuals who look over your blog post.

  2. Thanks for the nice comment.
    These all happens on my daily works.
    After 10 years I learn all the tricks from internet, I feel it is time to pay back.

    Best Regards,

  3. excellent points altogether, you just received brand new|a new} reader. What might you recommend in regards to your put up that you simply made some days in the past? Any sure?

  4. Wow! Thank you! I always wanted to write on my site something like that. Can I implement a portion of your post to my website?

  5. Sure, please do.