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
*
How it works

Next 5 Runs

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

* Tools

Code & Implementations

Bash
#!/bin/bash
# Production-ready Bash script with lock protection to prevent overlap
LOCKFILE="/var/lock/my_two_minute_job.lock"

# Acquire an exclusive lock without blocking
exec 200>"$LOCKFILE"
flock -n 200 || {
  echo "[$(date)] Warning: Job is already running, skipping execution to avoid overlap."
  exit 1
}

echo "[$(date)] Initiating high-frequency polling task..."
timeout 110s curl -s -f https://api.internal/v1/poll-tasks || {
  echo "[$(date)] Error: API request failed or timed out."
  exit 1
}

echo "[$(date)] Task completed successfully."
Setup notes

Place this script in /usr/local/bin/poll-job.sh, make it executable, and add '*/2 * * * * /usr/local/bin/poll-job.sh >> /var/log/poll-job.log 2>&1' to your system crontab.

Last verified:

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

Last verified:

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

Last verified:

Was this helpful?