You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/cron.md
+43-35Lines changed: 43 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,57 +10,66 @@ OpenFaaS Pro adds the ability to have a function invoked by Cron and any other n
10
10
11
11
* Deploy the connector with arkade or Helm
12
12
13
-
```sh
14
-
arkade install cron-connector
15
-
```
13
+
```sh
14
+
arkade install cron-connector
15
+
```
16
16
17
-
Or deploy for OpenFaaS Pro:
17
+
Or deploy for OpenFaaS Pro:
18
18
19
-
```bash
20
-
arkade install cron-connector \
21
-
--set openfaasPro=true
22
-
```
19
+
```bash
20
+
arkade install cron-connector \
21
+
--set openfaasPro=true
22
+
```
23
23
24
-
Alternatively, install with the [Helm chart](https://github.com/openfaas/cron-connector)
24
+
Alternatively, install with the [Helm chart](https://github.com/openfaas/cron-connector)
25
25
26
26
* Now annotate a functionwith a `topic` of `cron-function` and a `schedule` using a valid CRON expression:
27
27
28
-
```yaml
29
-
# (Abridged YAML)
28
+
```yaml
29
+
# (Abridged YAML)
30
30
31
-
functions:
32
-
nodeinfo:
33
-
image: ghcr.io/openfaas/nodeinfo
34
-
skip_build: true
35
-
annotations:
36
-
topic: cron-function
37
-
schedule: "*/5 * * * *"
38
-
```
39
-
*nodeinfo.yaml*
31
+
functions:
32
+
nodeinfo:
33
+
image: ghcr.io/openfaas/nodeinfo
34
+
skip_build: true
35
+
annotations:
36
+
topic: cron-function
37
+
schedule: "*/5 * * * *"
38
+
```
39
+
*nodeinfo.yaml*
40
40
41
-
```sh
42
-
faas-cli deploy -f nodeinfo.yaml
43
-
```
41
+
```sh
42
+
faas-cli deploy -f nodeinfo.yaml
43
+
```
44
44
45
-
* Or deploy directly from the store
45
+
* Or deploy directly from the store
46
46
47
-
```sh
48
-
faas-cli store deploy nodeinfo \
49
-
--annotation topic="cron-function" \
50
-
--annotation schedule="*/5 * * * *"
51
-
```
47
+
```sh
48
+
faas-cli store deploy nodeinfo \
49
+
--annotation topic="cron-function" \
50
+
--annotation schedule="*/5 * * * *"
51
+
```
52
52
53
53
* Check the logs for invocations:
54
54
55
-
```sh
56
-
kubectl logs -n openfaas-fn deploy/nodeinfo -f
57
-
```
55
+
```sh
56
+
kubectl logs -n openfaas-fn deploy/nodeinfo -f
57
+
```
58
58
59
-
You'll see the function invoked every 5 minutes as per the schedule.
59
+
You'll see the function invoked every 5 minutes as per the schedule.
60
+
61
+
* Multiple expressions can be added to the `schedule` annotation separated by a semicolon. The connector will schedule invocations for each cron expression.
62
+
63
+
```sh
64
+
faas-cli store deploy nodeinfo \
65
+
--annotation topic="cron-function" \
66
+
--annotation schedule="*/5 * * * *; * * * * 1,5"
67
+
```
60
68
61
69
* Disable a schedule
62
70
63
-
To stop the invocations, remove the two annotations or remove the cron-connector deployment.
71
+
To disable a schedule, remove the schedule from the `schedule` annotation.
72
+
To stop all invocations, remove the `schedule` and `topic` annotations from the function entirely or remove the cron-connector deployment.
64
73
65
74
66
75
If you would like to explore how to write CRON expressions, then see [https://crontab.guru/](https://crontab.guru/)
0 commit comments