Execute Jobs Every Five Minutes | CronBase

cron expression Standard
$ */5 * * * *

Every five minutes, continuously throughout the hour, day, and week.

The `*/5 * * * *` cron expression schedules a command to run repeatedly at five-minute intervals, specifically at minutes zero, five, ten, fifteen, and so on, every hour of every day. It is commonly used for high-frequency tasks like API polling, system health monitoring, and queue processing.

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

Next 5 Runs

  • in 2m 3s
  • in 7m 3s
  • in 12m 3s
  • in 17m 3s
  • in 22m 3s

* Tools

Code & Implementations

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

let isRunning = false;

// Schedule to run every 5 minutes
cron.schedule('*/5 * * * *', async () => {
    if (isRunning) {
        console.warn('Execution skipped: Previous task is still running.');
        return;
    }
    isRunning = true;
    try {
        console.log('Starting execution cycle...');
        await performTask();
    } catch (error) {
        console.error('Task failed:', error);
    } finally {
        isRunning = false;
    }
});

function performTask() {
    return new Promise((resolve) => setTimeout(resolve, 5000));
}
Setup notes

Install the node-cron package using 'npm install node-cron' and run this script as a daemon using a process manager like PM2 to ensure continuous execution.

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(*/5 * * * ? *)

Systemd Timer

OnCalendar*-*-* *:00/5:00

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

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

[Install]
WantedBy=timers.target

Frequently Asked Questions

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

Use a locking mechanism. In Bash, wrap your command with `flock -n /var/lock/myjob.lock`. In application code, implement a distributed lock using Redis (Redlock) or a database-backed state lock to ensure only one instance runs at a time.

Will changing the system timezone affect this 5-minute schedule?

Because this expression runs continuously every five minutes regardless of the hour or day, timezone shifts (such as Daylight Saving Time) will not interrupt the frequency. The job will continue to execute every five minutes, though timestamp logs will reflect the timezone change.

How can I monitor if my 5-minute cron job fails silently?

Implement 'dead man's switch' monitoring (e.g., Healthchecks.io or Opsgenie). Have your script send an HTTP ping to an external service at the end of each successful run. If the service doesn't receive a ping within 6 or 7 minutes, it triggers an alert.

What is the performance impact of running a database query every 5 minutes?

If the query is unindexed or scans large tables, it can degrade database performance and exhaust connection pools. Ensure your queries use indexes, keep connection durations short, use connection pooling, and implement strict read timeouts.

Can I offset this job to run at minutes 2, 7, 12 instead of 0, 5, 10?

Yes, you can shift the execution offset by changing the expression to `2/5 * * * *`. This is highly recommended in shared hosting or microservice environments to avoid resource spikes that occur when multiple jobs align at the top of the 5-minute mark.

* Explore

Related expressions you might need

Was this helpful?

Last verified: