Execute Jobs Every Two Minutes Reliably | CronBase

cron expression Standard
$ */2 * * * *

Every two minutes, continuously throughout every day.

The `*/2 * * * *` cron expression schedules a job to execute every two minutes, continuously, every single day. It is a high-frequency interval ideal for near-real-time operations, including processing queue messages, polling external APIs, and executing lightweight system health checks or monitoring agents.

Minute
*/2
Hour
*
Day of Month
*
Month
*
Day of Week
*

Next 5 Runs

  • in 5s
  • in 2m 5s
  • in 4m 5s
  • in 6m 5s
  • in 8m 5s

* Tools

Code & Implementations

nodejs
const cron = require('node-cron');
const axios = require('axios');

let isRunning = false;

// Schedule task to run every two minutes
cron.schedule('*/2 * * * *', async () => {
  if (isRunning) {
    console.warn('[Cron] Previous job is still running; skipping execution.');
    return;
  }

  isRunning = true;
  console.log('[Cron] Starting execution...');

  try {
    const response = await axios.get('https://api.internal/v1/health', { timeout: 10000 });
    console.log(`[Cron] System health status: ${response.data.status}`);
  } catch (error) {
    console.error('[Cron] Execution failed:', error.message);
  } finally {
    isRunning = false;
  }
});
Setup notes

Install dependencies using 'npm install node-cron axios'. Run this script using a process manager like PM2 to guarantee uptime.

Partner UptimeRobot

Keep this cron job monitored 24/7

UptimeRobot alerts you the moment a scheduled job stops responding. Free plan monitors up to 50 endpoints — no credit card required.

Platform Equivalents

AWS EventBridge

Standard cron expressions often need conversion for AWS EventBridge schedules.

EventBridge Rule
cron(*/2 * * * ? *)

Systemd Timer

OnCalendar*-*-* *:00/2:00

my-task.timer
[Unit]
Description=Timer for cron expression: */2 * * * *

[Timer]
OnCalendar=*-*-* *:00/2:00
Persistent=true

[Install]
WantedBy=timers.target

Frequently Asked Questions

How do I prevent overlapping executions if a job takes longer than two minutes?

Use a locking mechanism like flock in Bash, or set concurrencyPolicy: Forbid in Kubernetes. For application-level jobs, use Redis-based distributed locks (Redlock) or database flags to ensure only one instance runs at a time.

Will this high-frequency schedule impact my log storage and monitoring costs?

Yes, executing every two minutes generates 720 executions per day. Verbose logging will quickly inflate storage costs. Implement structured metrics (e.g., Prometheus) for success tracking and restrict stdout logs to warnings, errors, or execution summaries.

Is standard cron guaranteed to run precisely every 120 seconds?

Standard system cron daemons check schedules at the minute boundary. While it triggers every two minutes, minor scheduling latency (milliseconds to a few seconds) can occur depending on system load. If sub-second precision is required, use a dedicated queue worker or systemd timer.

How should I handle external API rate limits with a two-minute schedule?

Implement exponential backoff with jitter within your application logic. If an API returns a 429 Too Many Requests status, the job should fail gracefully or pause execution, alerting your monitoring system before retrying on the next scheduled run.

Can I run this schedule on a specific timezone instead of UTC?

Standard system cron runs on the host machine's timezone (usually UTC in cloud environments). If your cron daemon (like modern systemd or Kubernetes 1.27+) supports timezone fields, you can specify it, but keeping the system clock on UTC is the best practice to avoid daylight saving transitions.

* Explore

Related expressions you might need

Was this helpful?

Last verified: