Home โบ node-cron โบ Every 2 hours
node-cron cron expression: every 2 hours
To run a node-cron job every 2 hours, use:
0 */2 * * *At minute 0, every 2 hours.
Your week at a glance
Upcoming runs
| # | Local | UTC | From now |
|---|
Copy-ready code
Why use this schedule
Twelve runs a day, at even hours (00:00, 02:00, 04:00 and so on). It halves the load of an hourly job while still catching changes within a couple of hours.
- Pulling analytics exports
- Rebalancing a recommendation cache
- Checking certificate expiry
First runs, as an example
Starting from 1 January 2027, evaluated in UTC:
| # | Date and time (UTC) |
|---|---|
| 1 | Fri, 01 Jan 2027, 00:00:00 |
| 2 | Fri, 01 Jan 2027, 02:00:00 |
| 3 | Fri, 01 Jan 2027, 04:00:00 |
| 4 | Fri, 01 Jan 2027, 06:00:00 |
| 5 | Fri, 01 Jan 2027, 08:00:00 |
| 6 | Fri, 01 Jan 2027, 10:00:00 |
Every 2 hours in every dialect
| System | Expression |
|---|---|
| node-cron (this page) | 0 */2 * * * |
| Quartz | 0 0 */2 * * ? |
| Spring | 0 0 */2 * * * |
| Crontab | 0 */2 * * * |
| Kubernetes | 0 */2 * * * |
| AWS EventBridge | 0 */2 * * ? * |
| Jenkins | H */2 * * * |
| GitHub Actions | 0 */2 * * * |
| Apache Airflow | 0 */2 * * * |
| Azure Functions | 0 0 */2 * * * |
| Google Cloud Scheduler | 0 */2 * * * |
Need to translate a different expression? Use the cron converter.
Ready-to-use node-cron config
Drop this into your project. The expression is the one above.
import cron from 'node-cron';
cron.schedule('0 */2 * * *', () => {
console.log('running a task');
}, { timezone: 'UTC' });The node-cron fields, in order: second (0-59), minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (0-7, 0 and 7 = Sunday).
Things to watch out for in node-cron
- Steps restart at the top of each unit, as in standard cron, so */7 in minutes runs at 0, 7 ... 56 and then at 0 again.
- Five fields: minute, hour, day-of-month, month, day-of-week. Add a leading seconds field for sub-minute schedules.
- node-cron uses the server time zone unless you pass { timezone: "Asia/Kolkata" }. Its documentation advises timezone: "UTC" for jobs that must not skip or repeat when clocks change.
The common mistake with this schedule
The step restarts at midnight, so */2 always means the even hours. If you need odd hours use 1-23/2.
Frequently asked questions
How do I run a node-cron job every 2 hours?
Use 0 */2 * * *. At minute 0, every 2 hours.
What is the every 2 hours cron expression in other systems?
Quartz: 0 0 */2 * * ?; Spring: 0 0 */2 * * *; Crontab: 0 */2 * * *. The table on this page lists every dialect.
Which time zone does node-cron use for this schedule?
node-cron uses the server time zone unless you pass { timezone: "Asia/Kolkata" }. Its documentation advises timezone: "UTC" for jobs that must not skip or repeat when clocks change.