apoc.periodic.repeatProcedure
Syntax |
|
||
Description |
Runs a repeatedly called background job. To stop this procedure, use |
||
Input arguments |
Name |
Type |
Description |
|
|
The name of the job. |
|
|
|
The Cypher statement to run. |
|
|
|
The delay in seconds to wait between each job execution. |
|
|
|
|
|
Return arguments |
Name |
Type |
Description |
|
|
The name of the job. |
|
|
|
The delay on the job. |
|
|
|
The rate of the job. |
|
|
|
If the job has completed. |
|
|
|
If the job has been cancelled. |
Usage Examples
We can create 10 Person
nodes every second by running the following query:
CALL apoc.periodic.repeat(
"create-people",
"UNWIND range(1,10) AS id CREATE (:Person {uuid: apoc.create.uuid()})",
1
);
name | delay | rate | done | cancelled |
---|---|---|---|---|
"create-people" |
0 |
1 |
FALSE |
FALSE |
We can check how many nodes have been created by running the following query:
MATCH (:Person)
RETURN count(*) AS count;
count |
---|
110 |
If you want to cancel this job, you can use the apoc.periodic.cancel procedure and specify the name of the job as the argument.
Handling errorsCypher 25Introduced in 2025.08
By default, if a query run with apoc.periodic.repeat
returns an error, the task is canceled and will not be run again.
This behavior can be overridden using the config parameter: cancelOnError
.
The following query will create a Person
node with a random id
property.
However, when the expression toInteger(3 * rand())
evaluates to 0
, a division by zero error is thrown.
By setting cancelOnError
to false, this error will be ignored, and the task will be retried after one second.
CALL apoc.periodic.repeat(
"sometimes-create-people",
"CREATE (:Person {id: 1 / toInteger(3 * rand())})",
1,
{ cancelOnError: false }
);
name | delay | rate | done | cancelled |
---|---|---|---|---|
"sometimes-create-people" |
0 |
1 |
FALSE |
FALSE |