Automate Tasks Every 20 Minutes | CronBase

cron expression Standard
$ */20 * * * *

Every twenty minutes, recurring continuously throughout the day and night.

The `*/20 * * * *` cron expression schedules a task to run every twenty minutes, specifically at the zero, twenty, and forty-minute marks of every hour, every day. It is commonly used for recurring maintenance tasks, batch data pipelines, and API synchronization jobs that require frequent updates without overloading systems.

Minute
*/20
Hour
*
Day of Month
*
Month
*
Day of Week
*
How it works

Next 5 Runs

  • in 7m 32s
  • in 27m 32s
  • in 47m 32s
  • in 1h 7m
  • in 1h 27m

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
set -euo pipefail

# Use flock to prevent overlapping executions every 20 minutes
LOCKFILE="/var/lock/my-20min-job.lock"

exec 9>"$LOCKFILE"
if ! flock -n 9; then
  echo "Error: Another instance of the job is already running." >&2
  exit 1
fi

echo "Starting 20-minute maintenance task..."
# Place actual operational logic here (e.g., sync scripts, cleanup)
/usr/local/bin/sync-api-data.sh

echo "Task completed successfully."
Setup notes

Save this script to /usr/local/bin/sync-job.sh, make it executable with chmod +x, and add '*/20 * * * * /usr/local/bin/sync-job.sh' 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(*/20 * * * ? *)

Systemd Timer

OnCalendar*-*-* *:00/20:00

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

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

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

What exact minutes does this cron expression trigger on?

This cron expression triggers exactly at 0, 20, and 40 minutes past every hour (e.g., 12:00, 12:20, 12:40).

How can I prevent executions from overlapping if a task takes longer than 20 minutes?

Use file locks (`flock` in Linux), distributed lock managers like Redis (Redlock), or Kubernetes concurrency policy set to `Forbid` to ensure only one instance runs at a time.

Does this cron schedule adapt automatically to Daylight Saving Time (DST) changes?

Standard cron runs based on the host system's timezone. During DST shifts, the 20-minute interval remains consistent, but the absolute hour boundary may shift by one hour.

How does this schedule compare to running a task every 15 minutes?

A 20-minute interval reduces execution frequency from 96 times a day to 72 times a day, saving system resources and downstream API rate limits while maintaining a high frequency.

Can I run this schedule only during specific business hours?

Yes, you can restrict the hour field. For example, `*/20 9-17 * * *` will run the task every 20 minutes only between 9:00 AM and 5:59 PM.

* Explore

Related expressions you might need

Last verified:

Was this helpful?