简体   繁体   English

如何使用 PgAgent 在 PostgreSql 中创建 sScheduler 作业

[英]How to Create a sScheduler Job in PostgreSql using PgAgent

I'm new in PostgreSQL, and I want to create a scheduled job which is run every day.我是 PostgreSQL 的新手,我想创建一个每天运行的计划作业。

Firstly I'm creating a function for this.首先,我为此创建了一个函数。 my function is working fine.我的功能工作正常。

And now I want to create jobs and use this function inside the jobs, so it runs every day.现在我想创建工作并在工作中使用这个函数,所以它每天都在运行。

But I don't know how do this.但我不知道如何做到这一点。 I've been googling but didn't find any reference.我一直在谷歌搜索,但没有找到任何参考。

Please help请帮忙

在此处输入图像描述

Kindly follow the below steps:请按照以下步骤操作:

Step 1: install pgAgent using application stack builder of postgres第 1 步:使用 postgres 的应用程序堆栈构建器安装 pgAgent

Step 2:execute schema pgagent.sql in maintainance DB.follow this https://www.pgadmin.org/docs/pgadmin4/dev/pgagent_install.html link.第 2 步:在维护 DB 中执行模式 pgagent.sql。按照此https://www.pgadmin.org/docs/pgadmin4/dev/pgagent_install.html链接。

Step 3:Execute Following Command to pgAgent bin directory.步骤 3:对 pgAgent bin 目录执行以下命令。

   pgAgent REMOVE pgAgent

   pgAgent INSTALL pgAgent -u system_username -p system_password 
    hostaddr=127.0.0.1 dbname=xyz 
    user=postgres_password=password_for_database

Step 4: Create job.第四步:创建工作。 follow this https://www.pgadmin.org/docs/pgadmin4/dev/pgagent_jobs.html link.按照这个https://www.pgadmin.org/docs/pgadmin4/dev/pgagent_jobs.html链接。 in the sql You have to write select your_func_name();.在 sql 你必须写 select your_func_name();。

Step 5: Start job service using below command第 5 步:使用以下命令启动作业服务

    net start pgAgent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM