반응형
1. 설치
cd $HOME/postgresql-15.5/contrib wget https://github.com/citusdata/pg_cron/archive/refs/tags/v1.6.2.tar.gz tar -xvzf v1.6.2.tar.gz cd pg_cron-1.6.2 && make && make install |
2. 설정
$PGDATA/postgresql
shared_preload_libraries = 'pg_stat_statements,passwordcheck,pg_store_plans,pg_cron' cron.database_name='testdb1' |
$PGDATA/pg_hba.conf , $HOME/.pgpass 둘 중 하나 설정해서 자동접속 가능하게 만들어야함
local 세션 열고 접속 함 host all all 127.0 or 127.0.0.1:5432:*:pgre16:pgre16 |
3. 재기동 && Extenstion 설치
pg_ctl restart -mf |
4. 접속, 해당 DB에 Extension 설치 및 테스트
# 설정했던 DB로 접속 pgre16@oracle1 ~]$ psql -U pgre16 -d testdb1 Timing is on. Pager usage is off. psql (16.1) Type "help" for help. create extension pg_cron; select * from pg_extension; ![]() SELECT cron.schedule_in_database( 'testdb1_cron_insert', '*/1 * * * *', $$INSERT INTO public.test1db_tab1(name, age, create_date) VALUES ('A', '10', current_timestamp);$$, 'testdb1', 'pgre16' ); ---------------------- 1 (1 row) select jobid, schedule, command from cron.job; ![]() [local]:5432 pgre16@testdb1=#*select cron.unschedule(1); unschedule ------------ t (1 row) 비활성화 시키면 아에 제거됨 ※참고 ![]() |
5. 스펙확인
[local]:5432 pgre16@testdb1=#*\dx pg_cron List of installed extensions Name | Version | Schema | Description ---------+---------+------------+------------------------------ pg_cron | 1.6 | pg_catalog | Job scheduler for PostgreSQL |
반응형
'Database > Postgre' 카테고리의 다른 글
[POSTGRE] pg_bigm (0) | 2024.11.01 |
---|---|
[POSTGRE] pg_store_plans (1) | 2024.10.18 |
[POSTGRE] 패스워드 복잡성 설정 (0) | 2024.07.30 |
[POSTGRE] HBA등 설정파일 (0) | 2024.07.12 |
[POSTGRE] 수동 설치 (0) | 2023.12.15 |