Run Every 30 Minutes Cron Schedule | CronBase

cron expression Standard
$ */30 * * * *

Every half hour, running on the hour and thirty minutes past the hour, every day.

The `*/30 * * * *` cron expression schedules a task to execute every thirty minutes, specifically at the top of the hour and thirty minutes past the hour. This high-frequency cadence is commonly used for automated system health checks, periodic database cache invalidation, API synchronization, and active monitoring tasks.

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

Next 5 Runs

  • in 6m 19s
  • in 36m 19s
  • in 1h 6m
  • in 1h 36m
  • in 2h 6m

* Tools

Code & Implementations

Bash
#!/usr/bin/env bash
# Cron integration: Add this line to your crontab using 'crontab -e':
# */30 * * * * /usr/local/bin/db_cleanup.sh >> /var/log/db_cleanup.log 2>&1

set -euo pipefail

LOCKFILE="/var/tmp/db_cleanup.lock"

# Use flock to prevent concurrent execution if a previous run hangs
exec 9>"$LOCKFILE"
if ! flock -n 9; then
    echo "[$(date -u)] Warning: Another instance of db_cleanup is already running. Exiting." >&2
    exit 1
fi

echo "[$(date -u)] Starting database cleanup process..."
# Simulated payload
if ! pg_dump -U postgres -d production_db --schema-only > /dev/null; then
    echo "[$(date -u)] Error: Database backup check failed!" >&2
    exit 2
fi

echo "[$(date -u)] Database cleanup completed successfully."
Setup notes

Save this script to /usr/local/bin/db_cleanup.sh, make it executable with chmod +x, and configure your system crontab to execute it on the half-hour boundary.

Last verified:

Partner BetterStack

Monitor this schedule in production

Get alerted the moment this cron job fails, is late, or doesn't run. BetterStack tracks execution, duration, and output — no infrastructure required.

Platform Equivalents

AWS EventBridge

Standard cron expressions often need conversion for AWS EventBridge schedules.

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

Systemd Timer

OnCalendar*-*-* *:00/30:00

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

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

[Install]
WantedBy=timers.target

Last verified:

Frequently Asked Questions

How do I prevent two instances of this job from running concurrently?

Implement a locking mechanism. In Kubernetes, set concurrencyPolicy to Forbid. In Linux shell scripts, use the flock utility to acquire an exclusive lock on a file descriptor before executing the main payload.

What happens to this schedule during Daylight Saving Time (DST) transitions?

Because this cron runs twice an hour, DST shifts do not affect the interval consistency. The job will continue to run every thirty minutes without interruption, though the absolute wall-clock hour will change.

Can I offset this job to run at 15 and 45 minutes past the hour instead?

Yes, you can modify the expression to '15,45 * * * *'. This is highly recommended in shared environments to avoid the resource spikes associated with running exactly on the hour.

How should I monitor a job that runs at this frequency?

Implement dead man's snitch monitoring (heartbeat alerts). Since the job runs regularly, set up an alert that triggers if no successful execution ping is received within 35 to 40 minutes.

Is this schedule suitable for heavy database migrations or backups?

No, a thirty-minute interval is generally too frequent for heavy operations. If a backup fails or hangs, it can quickly cascade and deplete database connections. Use daily or weekly schedules for intensive tasks.

* Explore

Related expressions you might need

Last verified:

Was this helpful?