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
For a more complete example, refer to the [docs][d]. But this is the essence.
100
100
101
+
## Cron Style Job Scheduling
102
+
103
+
To schedule jobs to be enqueued at specific intervals, RQ >= 2.4 now provides a cron-like feature (support for cron syntax coming soon).
104
+
105
+
First, create a configuration file (e.g., `cron_config.py`) that defines the jobs you want to run periodically.
106
+
107
+
```python
108
+
from rq import cron
109
+
from myapp import cleanup_database, send_daily_report
110
+
111
+
# Run database cleanup every 5 minutes
112
+
cron.register(
113
+
cleanup_database,
114
+
queue_name='default',
115
+
interval=300# 5 minutes in seconds
116
+
)
117
+
118
+
# Send daily reports every 24 hours
119
+
cron.register(
120
+
send_daily_report,
121
+
queue_name='repeating_tasks',
122
+
args=('daily',),
123
+
kwargs={'format': 'pdf'},
124
+
interval=86400# 24 hours in seconds
125
+
)
126
+
```
127
+
128
+
And then start the `rq cron` command to enqueue these jobs at specified intervals:
129
+
130
+
```sh
131
+
$ rq cron cron_config.py
132
+
```
133
+
134
+
More details on functionality can be found in the [docs](https://python-rq.org/docs/cron/).
101
135
102
136
### The Worker
103
137
@@ -115,7 +149,7 @@ Job result = 818
115
149
To run multiple workers in production, use process managers like `systemd`. RQ also ships with a beta version of `worker-pool` that lets you run multiple worker processes with a single command.
116
150
117
151
```console
118
-
rq worker-pool -n 4
152
+
$ rq worker-pool -n 4
119
153
```
120
154
121
155
More options are documented on [python-rq.org](https://python-rq.org/docs/workers/).
0 commit comments