pg_cron插件已安装,具体用法见 github地址
1.定时脚本查询方法
select * from cron.job
数据库一直没看到数据同步,查看pg_cron日志说明,这么详细.....
2.只有自己摸索,这日志应该写在pg的日志中,locate pg的配置的文件
$ sudo locate postgresql.conf | tail -n 1
输出:
$ /var/lib/pgsql/11/data/postgresql.conf
3.搜索postgresql.conf,查看日志文件规则
sudo vim /var/lib/pgsql/11/data/postgresql.conf
4.日志的规则为postgresql-%a.log`, 搜索目录下的日志
sudo find /var/lib/pgsql -name postgresql-*.log
输出:
/var/lib/pgsql/11/data/log/postgresql-Tue.log
/var/lib/pgsql/11/data/log/postgresql-Wed.log
/var/lib/pgsql/11/data/log/postgresql-Mon.log
/var/lib/pgsql/11/data/log/postgresql-Fri.log
/var/lib/pgsql/11/data/log/postgresql-Thu.log
/var/lib/pgsql/11/data/log/postgresql-Sun.log
/var/lib/pgsql/11/data/log/postgresql-Sat.log
5.找到postgresql-Fri.log,并用vim搜索cron job关键字,终于出来logging庐山真面目了,pg_hba.conf配置问题
sudo vim /var/lib/pgsql/11/data/log/postgresql-Fri.log
2020-03-13 00:20:00.003 CST [10650] LOG: cron job 3 connection failed
2020-03-13 00:25:00.000 CST [10650] LOG: cron job 5 starting: SELECT f_pull('pg_cron import');
2020-03-13 00:25:00.002 CST [13650] LOG: could not connect to Ident server at address "::1", port 113: Connection refused
2020-03-13 00:25:00.002 CST [13650] FATAL: Ident authentication failed for user "postgres"
2020-03-13 00:25:00.002 CST [13650] DETAIL: Connection matched pg_hba.conf line 85: "host all all ::1/128 ident"