pg_cron is a simple cron-based job scheduler for PostgreSQL that runs inside the database as an extension.

Citus Banner

Slack Status

What is pg_cron?

pg_cron is a simple cron-based job scheduler for PostgreSQL (9.5 or higher) that runs inside the database as an extension. It uses the same syntax as regular cron, but it allows you to schedule PostgreSQL commands directly from the database:

-- Delete old data on Saturday at 3:30am (GMT)
SELECT cron.schedule('30 3 * * 6', $$DELETE FROM events WHERE event_time < now() - interval '1 week'$$);
 schedule
----------
       42

-- Vacuum every day at 10:00am (GMT)
SELECT cron.schedule('nightly-vacuum', '0 10 * * *', 'VACUUM');
 schedule
----------
       43

-- Change to vacuum at 3:00am (GMT)
SELECT cron.schedule('nightly-vacuum', '0 3 * * *', 'VACUUM');
 schedule
----------
       43

-- Stop scheduling jobs
SELECT cron.unschedule('nightly-vacuum' );
 unschedule 
------------
 t
(1 row)

SELECT cron.unschedule(42);
 unschedule
------------
          t

pg_cron can run multiple jobs in parallel, but it runs at most one instance of a job at a time. If a second run is supposed to start before the first one finishes, then the second run is queued and started as soon as the first run completes.

The schedule uses the standard cron syntax, in which * means "run every time period", and a specific number means "but only at this time":

 ┌───────────── min (0 - 59)
 │ ┌────────────── hour (0 - 23)
 │ │ ┌─────────────── day of month (1 - 31)
 │ │ │ ┌──────────────── month (1 - 12)
 │ │ │ │ ┌───────────────── day of week (0 - 6) (0 to 6 are Sunday to
 │ │ │ │ │                  Saturday, or use names; 7 is also Sunday)
 │ │ │ │ │
 │ │ │ │ │
 * * * * *

An easy way to create a cron schedule is: crontab.guru.

The code in pg_cron that handles parsing and scheduling comes directly from the cron source code by Paul Vixie, hence the same options are supported. Be aware that pg_cron always uses GMT!

Installing pg_cron

Install on Red Hat, CentOS, Fedora, Amazon Linux with PostgreSQL 12 using PGDG:

# Install the pg_cron extension
sudo yum install -y pg_cron_12

Install on Debian, Ubuntu with PostgreSQL 12 using apt.postgresql.org:

# Install the pg_cron extension
sudo apt-get -y install postgresql-12-cron

You can also install pg_cron by building it from source:

git clone https://github.com/citusdata/pg_cron.git
cd pg_cron
# Ensure pg_config is in your path, e.g.
export PATH=/usr/pgsql-12/bin:$PATH
make && sudo PATH=$PATH make install

Setting up pg_cron

To start the pg_cron background worker when PostgreSQL starts, you need to add pg_cron to shared_preload_libraries in postgresql.conf. Note that pg_cron does not run any jobs as a long a server is in hot standby mode, but it automatically starts when the server is promoted.

By default, the pg_cron background worker expects its metadata tables to be created in the "postgres" database. However, you can configure this by setting the cron.database_name configuration parameter in postgresql.conf.

# add to postgresql.conf:
shared_preload_libraries = 'pg_cron'
cron.database_name = 'postgres'

After restarting PostgreSQL, you can create the pg_cron functions and metadata tables using CREATE EXTENSION pg_cron.

-- run as superuser:
CREATE EXTENSION pg_cron;

-- optionally, grant usage to regular users:
GRANT USAGE ON SCHEMA cron TO marco;

Important: Internally, pg_cron uses libpq to open a new connection to the local database. It may be necessary to enable trust authentication for connections coming from localhost in pg_hba.conf for the user running the cron job. Alternatively, you can add the password to a .pgpass file, which libpq will use when opening a connection.

For security, jobs are executed in the database in which the cron.schedule function is called with the same permissions as the current user. In addition, users are only able to see their own jobs in the cron.job table.

Example use cases

Articles showing possible ways of using pg_cron:

Managed services

The following table keeps track of which of the major managed Postgres services support pg_cron.

Service Supported
Aiven ✔️
Alibaba Cloud ✔️
Amazon RDS ✔️
Azure ✔️
Citus Cloud ✔️
Crunchy Bridge ✔️
DigitalOcean ✔️
Google Cloud
Heroku
ScaleGrid ✔️
Scaleway ✔️
Supabase ✔️
Owner
Citus Data
Scalable PostgreSQL
Citus Data
Comments
  • Log cron job results in a table

    Log cron job results in a table

    Currently, pg_cron does not give much feedback on the outcome of cron jobs other than what is available from the PostgreSQL log. Add logic to update the cron.result table as tasks progress. Optionally, add a cron job to clean up the table.

  • Memory leak

    Memory leak

    After a week running pg_cron we noticed an increase in memory usage, like we had in the past #26 :

      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3588 postgres  20   0   16.1g  14.9g 265240  15.0g  89704 S   0.0 24.0   4:57.82 postgres: change me: pg_cron launcher
    

    But looking at the repository, the branch fix_memory_leak is not there anymore.

  • Can't dump pg_cron schema

    Can't dump pg_cron schema

    PostgreSQL 10 from PGDG, Ubuntu 18.10:

    Check PG config:

    [email protected]_probackup:~$ grep cron /etc/postgresql/10/main/conf.d/local.conf
    shared_preload_libraries = 'pg_cron'
    cron.database_name = 'postgres'
    
    

    Show jobs:

    [email protected]_probackup:~$ psql -U postgres -c '\x' -c 'select * from cron.job'
    Expanded display is on.
    -[ RECORD 1 ]----------------------------------------------
    jobid    | 2
    schedule | */1 * * * *
    command  | insert into testdata (testdata) values ('cron');
    nodename | localhost
    nodeport | 5432
    database | testdb
    username | postgres
    active   | t
    
    

    And now dump DB postgres

    [email protected]_probackup:~$ pg_dump -U postgres -f postgres.sql
    
    

    Result in attach. What is wrong? postgres.sql.gz

  • pg_cron never ends job of

    pg_cron never ends job of "VACUUM VERBOSE"

    When I schedule a job of "VACUUM VERBOSE" or "VACUUM (VERBOSE, ANALYZE)" pg_cron executes job but never completes it. Specifically in "cron.job_run_details" the "end_time" column remains null.

    Screen Shot 2021-09-07 at 4 13 57 PM

    Ended up having to manually cancel vacuum jobs that were "VERBOSE". I think the issue might be the output of the job is not suitable for return_message... which somehow causes the job to not exit properly... really just speculation though. Replicated this behavior in multiple databases.

    Screen Shot 2021-09-07 at 4 23 50 PM
  • Not able to make pg_cron work

    Not able to make pg_cron work

    This seems to be a very useful project and appreciate Citusdata opensourcing it. I have tried this in both 9.6 and 10 ( single node default installation ) and did exactly as the instructions have said, but after several hours I cannot seem to make it work in both cases.

    Environment: Plain vanilla installation of PG 9.6 and PG 10 on Ubuntu

    1. I create a testcron table with id int , insert_time timestampz default now()
    2. I create a cron job using the syntax with SELECT cron.schedule('1 * * * *', $$insert into testcron values(1)$$); or SELECT cron.schedule('1 * * * *', $$delete from testcron where id = 1$$);
    3. It creates the job but doesn't do anything after 1 minute.
  • Pg_cron crontab log

    Pg_cron crontab log

    We're trying to configure periodic jobs in PostgreSQL. To do this, we installed on Linux machine, with Postgres 9.6 running, the pg_cron project.

    System information:

    OS: Linux pg 4.4.0-72-generic #93-Ubuntu SMP PG: Postgres 9.6.3 installed from repo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main'

    Following the instructions in the pg_cron repository, we set in postgresql.conf the configuration below:

    shared_preload_libraries = 'pg_cron'
    cron.database_name = 'our db_name'

    Then, on db_name, we created the EXTENSION pg_cron

    CREATE EXTENSION pg_cron; and we scheduled our first Postgres job:

    SELECT cron.schedule('45 12 * * *', $$CREATE TABLE schema.testCron AS Select 'Test Cron' as Cron$$); So, jobid 1 was created and listed in table cron.job.

    We expected that at 12:45 the command of the scheduled job would have been launched. But nothing happened.

    The testCron table was not created and we had no trace in any logs.

    We also defined LOG_FILE in /usr/src/pg_cron/include/pathnames.h to enable logging.

    But, after re-compiling the project and restarting the Postgres service, we did not track log for pg_cron.

    How can we enable logs for pg_cron to check scheduling result?

    Thanks in advance!

  • background worker huge memory allocation

    background worker huge memory allocation

    We're seeing this behavior which is more perceptible when using many jobs scheduled on pg_cron.

    This is the situation after one week with 400 jobs:

      PID USER      PR  NI    VIRT    RES    SHR   USED S  %CPU %MEM     TIME+ COMMAND
     1786 postgres  20   0 9766.3m 4.181g   3228 4.181g S   0.0 22.0   0:38.14 postgres: bgworker: pg_cron_scheduler
    

    As shown the shared memory is aroung 3.2MB and the process memory is 4.1GB.

    The version where the issue was detected is PostgreSQL 9.5.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit, but also occurs on PostgreSQL 9.5.7 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit.

    Bellow there are the SQL commands creating jobs and the top measurements showing the memory increase:

    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) values ('* * * * *', 'select 1', 'localhost', '5432', 'postgres', 'postgres');
                  now              
    -------------------------------
     2017-06-01 10:58:28.591112-03
    (1 row)
    INSERT 0 1
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                 now              
    ------------------------------
     2017-06-01 10:58:48.90418-03
    (1 row)
    INSERT 0 1
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 10:59:43.526128-03
    (1 row)
    INSERT 0 2
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 11:00:04.406233-03
    (1 row)
    INSERT 0 4
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 11:00:20.862736-03
    (1 row)
    INSERT 0 8
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 11:00:49.438208-03
    (1 row)
    INSERT 0 16
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 11:01:27.310265-03
    (1 row)
    INSERT 0 32
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 11:01:56.518833-03
    (1 row)
    INSERT 0 64
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 11:02:23.070821-03
    (1 row)
    INSERT 0 128
    postgres=# select now(); insert into cron.job (schedule, command, nodename, nodeport, database, username) select schedule, command, nodename, nodeport, database, username from cron.job;
                  now              
    -------------------------------
     2017-06-01 11:02:51.662401-03
    (1 row)
    INSERT 0 256
    postgres=# select version();
                                             version                                          
    ------------------------------------------------------------------------------------------
     PostgreSQL 9.5.7 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit
    (1 row)
    [email protected]:~ $ top -b -d 30 -p 3988 | egrep "(load|pg_cron|USED)"
    top - 10:57:44 up 37 min,  6 users,  load average: 0.25, 0.20, 0.13
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  232452   8700   6624   8700      0 S   0.0  0.0   0:00.00 postgres: bgworker: pg_cron_scheduler
    top - 10:58:14 up 38 min,  6 users,  load average: 0.29, 0.22, 0.13
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  232452   8700   6624   8700      0 S   0.0  0.0   0:00.00 postgres: bgworker: pg_cron_scheduler
    top - 10:58:44 up 38 min,  6 users,  load average: 0.25, 0.21, 0.13
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  232452   8700   6624   8700      0 S   0.0  0.0   0:00.00 postgres: bgworker: pg_cron_scheduler
    top - 10:59:14 up 39 min,  6 users,  load average: 0.22, 0.21, 0.13
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  239028  11208   8896  11208      0 S   0.0  0.0   0:00.00 postgres: bgworker: pg_cron_scheduler
    top - 10:59:44 up 39 min,  6 users,  load average: 0.13, 0.18, 0.13
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  239028  11208   8896  11208      0 S   0.0  0.0   0:00.00 postgres: bgworker: pg_cron_scheduler
    top - 11:00:14 up 40 min,  6 users,  load average: 0.08, 0.17, 0.12
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  239028  11272   8896  11272      0 S   0.0  0.0   0:00.01 postgres: bgworker: pg_cron_scheduler
    top - 11:00:44 up 40 min,  6 users,  load average: 0.05, 0.15, 0.11
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  239028  11272   8896  11272      0 S   0.0  0.0   0:00.01 postgres: bgworker: pg_cron_scheduler
    top - 11:01:14 up 41 min,  6 users,  load average: 0.03, 0.13, 0.11
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  240120  11596   8896  11596      0 S   0.0  0.0   0:00.02 postgres: bgworker: pg_cron_scheduler
    top - 11:01:44 up 41 min,  6 users,  load average: 0.02, 0.12, 0.10
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  240120  11596   8896  11596      0 S   0.0  0.0   0:00.02 postgres: bgworker: pg_cron_scheduler
    top - 11:01:45 up 41 min,  6 users,  load average: 0.02, 0.12, 0.10
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  240120  11596   8896  11596      0 S   0.0  0.0   0:00.02 postgres: bgworker: pg_cron_scheduler
    top - 11:02:15 up 42 min,  6 users,  load average: 0.01, 0.11, 0.10
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  243640  12836   8928  12836      0 S   0.1  0.0   0:00.05 postgres: bgworker: pg_cron_scheduler
    top - 11:02:45 up 42 min,  6 users,  load average: 0.00, 0.09, 0.09
      PID USER      PR  NI    VIRT    RES    SHR   USED   SWAP S  %CPU %MEM     TIME+ COMMAND
     3988 pinogy    20   0  243640  13100   8936  13100      0 S   0.0  0.0   0:00.06 postgres: bgworker: pg_cron_scheduler
    top - 11:03:15 up 43 min,  6 users,  load average: 0.00, 0.08, 0.09
    
  • getting error in running below command after cloning this repo and setting path

    getting error in running below command after cloning this repo and setting path

    Machine : ubuntu:16.04 postgreSQL : 9.5 ~/pg_cron-main$ make && sudo PATH=$PATH make install

    gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -DMAP_HUGETLB=0x40000 -fPIC -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Iinclude -I/opt/PostgreSQL/10/include -I. -I./ -I/opt/PostgreSQL/10/include/postgresql/server -I/opt/PostgreSQL/10/include/postgresql/internal -I/opt/local/Current/include -D_GNU_SOURCE -I/opt/local/Current/include/libxml2 -I/opt/local/Current/include -c -o src/job_metadata.o src/job_metadata.c src/job_metadata.c: In function ‘GetRoleOidIfCanLogin’: src/job_metadata.c:380:14: error: ‘FormData_pg_authid {aka struct FormData_pg_authid}’ has no member named ‘oid’ return rform->oid; ^ src/job_metadata.c:381:1: error: control reaches end of non-void function [-Werror=return-type] } ^ src/job_metadata.c: At top level: cc1: error: unrecognized command line option ‘-Wno-implicit-fallthrough’ [-Werror] cc1: all warnings being treated as errors : recipe for target 'src/job_metadata.o' failed make: *** [src/job_metadata.o] Error 1

  • Can not create extension

    Can not create extension

    When I try to create extension on the database this is the error that I get

    CREATE EXTENSION pg_cron;
    

    ERROR: unrecognized configuration parameter "cron.database_name" CONTEXT: PL/pgSQL function inline_code_block line 3 at IF

  • The smallest unit that supports pg_cron is the granularity of seconds…

    The smallest unit that supports pg_cron is the granularity of seconds…

    …. If you need to contact me, my email: [email protected] comes from Xi’an, China. Thanks

    E.g:

    postgres=# SELECT cron.schedule('hasname', '*/30 * * * * *', 'select * from pg_extension'); schedule

        1
    

    (1 row)

    postgres=#
    2021-09-08 14:43:30.005 CST [58336] LOG: cron job 1 starting: select * from pg_extension 2021-09-08 14:43:30.091 CST [58336] LOG: cron job 1 completed: 2 rows 2021-09-08 14:44:00.004 CST [58336] LOG: cron job 1 starting: select * from pg_extension 2021-09-08 14:44:00.095 CST [58336] LOG: cron job 1 completed: 2 rows

  • 1.4.1 build error on Fedora 36

    1.4.1 build error on Fedora 36

    Hi,

    pg_cron does not build on Fedora 36, GCC 12.1:

    /usr/lib64/ccache/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -O2 -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-implicit-fallthrough -Iinclude -I/usr/pgsql-14/include -I. -I./ -I/usr/pgsql-14/include/server -I/usr/pgsql-14/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o src/entry.bc src/entry.c /usr/lib64/ccache/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -O2 -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-maybe-uninitialized -Wno-implicit-fallthrough -Iinclude -I/usr/pgsql-14/include -I. -I./ -I/usr/pgsql-14/include/server -I/usr/pgsql-14/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o src/job_metadata.bc src/job_metadata.c error: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Werror,-Wunknown-warning-option] make[1]: *** [/usr/pgsql-14/lib/pgxs/src/makefiles/../../src/Makefile.global:1070: src/entry.bc] Error 1 make[1]: *** Waiting for unfinished jobs.... error: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Werror,-Wunknown-warning-option] make[1]: *** [/usr/pgsql-14/lib/pgxs/src/makefiles/../../src/Makefile.global:1070: src/job_metadata.bc] Error 1 make[1]: Leaving directory '/var/lib/pgsql/rpm14/BUILD/pg_cron-1.4.1' error: Bad exit status from /var/tmp/rpm-tmp.VOWhr9 (%build)

    Can you please take a look?

    Regards, Devrim

  • When hour field is set, then rule does not run

    When hour field is set, then rule does not run

    A picture is worth a thousand words. image image

    at this moment I have just verified that there is a bug with pg_cron (all versions) where it is not possible to execute a pg_cron rule when the field corresponding to the time is filled with a constant value (Ex. 09 13 * * * ), however, if the value contains an asterisk, then it will work (Ex. 09 * * * *)

    Evidence can be seen in the images above. Therefore, I request a solution to this problem.

  • build gives warnings when using '-Wshadow=compatible-local'

    build gives warnings when using '-Wshadow=compatible-local'

    Hi,

    When I used -Wshadow=compatible-local flag, make command gives these warnings:

    ccache cc -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation -Wall -fPIC -fvisibility=hidden -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Iinclude -I/tmp/meson-install/include -I. -I./ -I/tmp/meson-install/include/postgresql/server -I/tmp/meson-install/include/postgresql/internal  -D_GNU_SOURCE  -c -o src/task_states.o src/task_states.c -MMD -MP -MF .deps/task_states.Po
    src/task_states.c: In function ‘RefreshTaskHash’:
    src/task_states.c:103:13: error: declaration of ‘task’ shadows a previous local [-Werror=shadow=compatible-local]
      103 |   CronTask *task = GetCronTask(job->jobId);
          |             ^~~~
    src/task_states.c:83:12: note: shadowed declaration is here
       83 |  CronTask *task = NULL;
          |            ^~~~
    cc1: all warnings being treated as errors
    

    Thanks!

  • Make it available (again) on PGXN

    Make it available (again) on PGXN

    pg_cron does not appear on pgxn.org. It would be convenient to have it on there. It looks like there's already the necessary (albeit outdated) META.json in this repository.

  • cron.unschedule(jobname) doesn't work

    cron.unschedule(jobname) doesn't work

    Hello,

    
    postgres 14.5 
    pg_cron 1.4.2
    
    

    Here's my table cron.job:

    
    [local]:5432 [email protected]=# select * from cron.job ;
     jobid |  schedule  |    command    | nodename  | nodeport | database | username | active | jobname
    -------+------------+---------------+-----------+----------+----------+----------+--------+---------
        17 | 10 * * * * | select now(); | localhost |     5432 | alpaca   | alpaca   | t      | peter
        18 | 10 * * * * | select now(); | localhost |     5432 | alpaca   | alpaca   | t      | peter2
        20 | 10 * * * * | select now(); | localhost |     5432 | alpaca   | alpaca   | t      | peter3
    (3 rows)
    
    

    When I try to run unschedule(jobname) I get the following error:

    
    [local]:5432 [email protected]=# select cron.unschedule('peter3') ;
    ERROR:  could not find valid entry for job 'peter3'
    
    

    both unschedule functions are present:

    
    [local]:5432 [email protected]=# \df
                                                                                                                      List of functions
    
    ... 
     cron   | unschedule           | boolean          | job_id bigint                                              | func
     cron   | unschedule           | boolean          | job_name name                                        | func
    
    ... 
    (7 rows)
    
    

    What am I missing?

    kr p.

  • pg_cron for PostgreSQL 12 stops working with message LOG: cron job 1 job startup timeout

    pg_cron for PostgreSQL 12 stops working with message LOG: cron job 1 job startup timeout

    Hello,

    I have set up pg_cron on PostgreSQL 12 on production server. It was working properly. Suddenly it stops working with message LOG: cron job 1 job startup timeout.

    I have tried below options still getting same message.

    1. I have restarted PostgreSQL service.
    2. Tried to create new job and tested.
    3. Removed pg_cron extension and recreated it. There is no pg_cron parameter available to change timeout value.

    As per analysis this is the log. And job command didn't start within 10 sec so it was timeout.

    2022-10-06 15:35:00.000 CEST [8334] DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 2022-10-06 15:35:00.000 CEST [8334] DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 51366430/1/0 2022-10-06 15:35:00.000 CEST [8334] DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 2022-10-06 15:35:00.001 CEST [8334] DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 51366431/1/1 2022-10-06 15:35:00.001 CEST [8334] LOG: cron job 1 starting: Refresh Materialized view CONCURRENTLY vw_publicmap_moor; 2022-10-06 15:35:00.001 CEST [8334] DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 2022-10-06 15:35:00.001 CEST [8334] DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 51366432/1/1 2022-10-06 15:35:10.000 CEST [8334] DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 2022-10-06 15:35:10.000 CEST [8334] DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 51366445/1/1 2022-10-06 15:35:10.000 CEST [8334] LOG: cron job 1 job startup timeout

    How to resolve this issue ?

  • cron.schedule is inserting corrupt job name

    cron.schedule is inserting corrupt job name

    SELECT cron.schedule('EXPORT ec3cedbf-2068-4292-9e72-4a3109371714 uat','00 00 04 10 *',
    $CRON$
    select 1;
    $CRON$)
    

    Inserts a job with a job name of

    XPORT ec3cedbf-2068-4292-9e72-4a3

    The whole job row looks like this:

    "jobid" "schedule" "command" "nodename" "nodeport" "database" "username" "active" "jobname"

    561 "00 00 04 10 *" "select 1;" "localhost" 5432 "uat2_main" "acme" true "XPORT ec3cedbf-2068-4292-9e72-4a3"

    We have pg cron version 1.3: "oid" "extname" "extowner" "extnamespace" "extrelocatable" "extversion" "extconfig" "extcondition" "372301083" "pg_cron" "10" "2200" false "1.3" "{372301087,372301085,372301109,372301107}" "{"""","""","""",""""}"

Sqrt OS is a simulation of an OS scheduler and memory manager using different scheduling algorithms including Highest Priority First (non-preemptive), Shortest Remaining Time Next, and Round Robin.
Sqrt OS is a simulation of an OS scheduler and memory manager using different scheduling algorithms including Highest Priority First (non-preemptive), Shortest Remaining Time Next, and Round Robin.

A CPU scheduler determines an order for the execution of its scheduled processes; it decides which process will run according to a certain data structure that keeps track of the processes in the system and their status. A process, upon creation, has one of the three states: Running, Ready, Blocked (doing I/O, using other resources than CPU or waiting on unavailable resource).

Apr 15, 2022
Simple and lightweight pathname parser for C. This module helps to parse dirname, basename, filename and file extension .
Simple and lightweight pathname parser for C. This module helps to parse dirname, basename, filename and file extension .

Path Module For C File name and extension parsing functionality are removed because it's difficult to distinguish between a hidden dir (ex: .git) and

Feb 25, 2022
A interpreter that runs the script which is programmed in the language of FF0 script (or you can call it as Warfarin)

ff0-script A interpreter that runs the script which is programmed in the language of FF0 script (or you can call it as Warfarin) You can do it, unders

Apr 27, 2022
Extension to Keyboard.h to allow non-US keyboards and Unicode characters

KeyboardUTF8 This Arduino library adds a mapping layer on top of the Keyboard library (for Leonardo/Micro/Due) to allow non-US keyboards and 'typing'

Sep 4, 2022
Simple .INI file parser in C, good for embedded systems

inih (INI Not Invented Here) inih (INI Not Invented Here) is a simple .INI file parser written in C. It's only a couple of pages of code, and it was d

Nov 21, 2022
Libelf is a simple library to read ELF files

libelf Libelf is a simple library which provides functions to read ELF files. Headers #include <stdint.h> #include <elf.h> Structures typedef struct

Aug 7, 2022
ByteCopy , or BCP, intends to copy files accurately (down to the bytes) in a simple , safe and efficient manner.

ByteCopy v3.6 About ByteCopy , or BCP, intends to copy files accurately (down to the bytes) in a simple , safe and efficient manner. It's functionalit

Jun 22, 2022
Simple Virtual Machine with its own Bytecode and Assembly language.
Simple Virtual Machine with its own Bytecode and Assembly language.

BM Simple Virtual Machine with its own Bytecode and Assembly language. Build We are using nobuild build system which requires a bootstrapping step wit

Nov 13, 2022
Documenting the development of a simple first module.

Your First Module This guide will look at writing a complete module, with many common features in a reduced form. This includes the module initialisat

Jun 3, 2021
A simple and easy-to-use library to enjoy videogames programming

hb-raylib v3.5 Harbour bindings for raylib 3.5, a simple and easy to use library to learn videogames programming raylib v3.5. The project has an educa

Aug 28, 2022
Dead simple C logging library contained in a single header (.h) file
Dead simple C logging library contained in a single header (.h) file

Seethe Logging so simple, you only need to include a single header file. seethe supports 6 different log levels (DEBUG, INFO, NOTICE, WARNING, ERROR,

May 9, 2022
A simple application that generates animated BTTV emotes from static images

emoteJAM WARNING! The application is in active development and can't do anything yet. A simple application that generates animated BTTV emotes from st

Apr 27, 2021
mathia : a simple computer algebra system in C++.

mathiu.cpp mathiu : a simple computer algebra system in C++ The library originated as a demo library showing the usage of the C++ pattern matching lib

Sep 17, 2022
Haxe bindings for raylib, a simple and easy-to-use library to learn videogame programming
Haxe bindings for raylib, a simple and easy-to-use library to learn videogame programming

Haxe bindings for raylib, a simple and easy-to-use library to learn videogame programming, Currently works only for windows but feel free the expand t

Nov 9, 2022
Simple password/cookies/history/bookmarks stealer/dumper for chrome all version (includes 80+)
Simple password/cookies/history/bookmarks stealer/dumper for chrome all version (includes 80+)

Simple password/cookies/history/bookmarks stealer/dumper for chrome all version (includes 80+), microsoft edge browser,includes all chromium based browsers, and all gecko based browser (firefox etc.).

Oct 27, 2022
This is a simple C++ implementation of plant-like structures defined with bracketed OLsystems.
This is a simple C++ implementation of plant-like structures defined with bracketed OLsystems.

Tree Hundred This is a simple C++ implementation of plant-like structures defined with bracketed OLsystems, as described in the book The Algorithmic B

Apr 22, 2022
libnpy is a simple C++ library for reading and writing of numpy's .npy files.

C++ library for reading and writing of numpy's .npy files

Nov 22, 2022
Simple yet fancy CPU architecture fetching tool
Simple yet fancy CPU architecture fetching tool

Simple yet fancy CPU architecture fetching tool

Nov 23, 2022
A simple program to suspend or hibernate your computer

A simple program to suspend or hibernate your computer. It supports hooks before and after suspending.

Nov 9, 2022