Execute Tasks Every Ten Minutes | CronBase
*/10 * * * * Every ten minutes, continuously throughout the day, every day of the week, and every month of the year.
The `*/10 * * * *` cron expression schedules a task to run automatically every ten minutes. This execution occurs at the start of every ten-minute interval throughout the hour, specifically at minutes zero, ten, twenty, thirty, forty, and fifty, recurring continuously every day of the year.
- Minute
- */10
- Hour
- *
- Day of Month
- *
- Month
- *
- Day of Week
- *
Next 5 Runs
- in 6m 19s
- in 16m 19s
- in 26m 19s
- in 36m 19s
- in 46m 19s
* Tools
Code & Implementations
#!/usr/bin/env bash
# Production Bash script for a 10-minute cron job.
# Uses flock to prevent overlapping execution.
set -euo pipefail
LOCKFILE="/var/lock/my_ten_minute_job.lock"
exec 9>"$LOCKFILE"
if ! flock -n 9; then
echo "Error: Job is already running. Exiting to prevent overlap." >&2
exit 1
fi
echo "[$(date -u)] Starting high-frequency sync task..."
# Simulate work
sleep 5
echo "[$(date -u)] Task completed successfully." › Setup notes
Save this script to /usr/local/bin/sync-task.sh, make it executable with chmod +x, and add the entry to your system crontab using crontab -e: */10 * * * * /usr/local/bin/sync-task.sh
const cron = require('node-cron');
// Schedule task to run every 10 minutes safely
let isRunning = false;
cron.schedule('*/10 * * * *', async () => {
if (isRunning) {
console.warn('[Warning] Previous execution still running. Skipping this interval.');
return;
}
isRunning = true;
try {
console.log(`[${new Date().toISOString()}] Starting database cleanup...`);
await performCleanup();
} catch (error) {
console.error('[Error] Execution failed:', error);
} finally {
isRunning = false;
}
});
async function performCleanup() {
// Simulated async operation
return new Promise(resolve => setTimeout(resolve, 2000));
} › Setup notes
Install node-cron using npm install node-cron, then run this file using node scheduler.js. The process must run as a background daemon using a manager like PM2.
import os
import sys
import fcntl
import time
# Production Python script utilizing file locking to prevent overlap when run via cron
LOCK_FILE = "/tmp/python_ten_minute_job.lock"
def main():
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Starting data sync pipeline...")
# Simulate heavy processing
time.sleep(10)
print("Sync complete.")
if __name__ == "__main__":
lock_fd = open(LOCK_FILE, 'w')
try:
# Acquire an exclusive lock without blocking
fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
print("Another instance of the script is already running. Exiting safely.", file=sys.stderr)
sys.exit(0)
try:
main()
finally:
fcntl.flock(lock_fd, fcntl.LOCK_UN) › Setup notes
Deploy this script on your Linux environment and schedule it using crontab -e with standard path definitions to ensure Python executes it every ten minutes.
package main
import (
"context"
"log"
"sync/atomic"
"time"
"github.com/robfig/cron/v3"
)
func main() {
c := cron.New()
var isRunning int32
// Schedule to run every 10 minutes
_, err := c.AddFunc("*/10 * * * *", func() {
// Prevent concurrent runs using atomic CAS
if !atomic.CompareAndSwapInt32(&isRunning, 0, 1) {
log.Println("[Warning] Task is already running; skipping execution.")
return
}
defer atomic.StoreInt32(&isRunning, 0)
ctx, cancel := context.WithTimeout(context.Background(), 8*time.Minute)
defer cancel()
if err := runTask(ctx); err != nil {
log.Printf("[Error] Task failed: %v", err)
}
})
if err != nil {
log.Fatalf("Failed to schedule cron job: %v", err)
}
c.Start()
select {} // Keep application running
}
func runTask(ctx context.Context) error {
log.Println("Starting 10-minute telemetry check...")
select {
case <-time.After(5 * time.Second):
log.Println("Telemetry check completed.")
case <-ctx.Done():
return ctx.Err()
}
return nil
} › Setup notes
Include github.com/robfig/cron/v3 in your go.mod file. Build and execute the binary inside a persistent Docker container or daemon process.
package com.example.cron;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.concurrent.atomic.AtomicBoolean;
@Component
public class TenMinuteTaskScheduler {
private static final Logger log = LoggerFactory.getLogger(TenMinuteTaskScheduler.class);
private final AtomicBoolean isRunning = new AtomicBoolean(false);
// Runs every 10 minutes (standard cron syntax)
@Scheduled(cron = "*/10 * * * *")
public void executeTask() {
if (!isRunning.compareAndSet(false, true)) {
log.warn("Previous execution is still running. Skipping this run.");
return;
}
try {
log.info("Starting ten-minute cache eviction process...");
performEviction();
} catch (Exception e) {
log.error("Error occurred during cache eviction", e);
} finally {
isRunning.set(false);
}
}
private void performEviction() throws InterruptedException {
// Simulate processing time
Thread.sleep(3000);
log.info("Cache eviction process completed successfully.");
}
} › Setup notes
Ensure @EnableScheduling is declared on your main Spring Boot Application class. Spring will parse the cron syntax automatically and execute the bean method.
apiVersion: batch/v1
kind: CronJob
metadata:
name: ten-minute-data-sync
namespace: default
spec:
schedule: "*/10 * * * *"
concurrencyPolicy: Forbid # Crucial: Prevents concurrent runs if a job hangs
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
activeDeadlineSeconds: 540 # Automatically terminate if running over 9 minutes
template:
spec:
containers:
- name: sync-worker
image: registry.example.com/sync-worker:v1.2.0
resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "500m"
restartPolicy: OnFailure › Setup notes
Apply this configuration to your Kubernetes cluster using kubectl apply -f cronjob.yaml. Always configure concurrencyPolicy to prevent resource leaks.
Last verified:
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.
cron(*/10 * * * ? *) Systemd Timer
OnCalendar*-*-* *:00/10:00
[Unit]
Description=Timer for cron expression: */10 * * * *
[Timer]
OnCalendar=*-*-* *:00/10:00
Persistent=true
[Install]
WantedBy=timers.target
Last verified:
Frequently Asked Questions
What happens if a job takes longer than 10 minutes to run?
If a job exceeds the 10-minute window, standard cron will launch a concurrent instance. To prevent resource starvation and race conditions, use locking tools like flock in Bash, or set concurrencyPolicy: Forbid in Kubernetes CronJobs to ensure only one instance runs at a time.
How can I stagger this job to avoid peak-hour load spikes?
Instead of running exactly on the tens (0, 10, 20...), you can introduce a minute offset. For example, using '3-59/10 * * * *' will run at minutes 3, 13, 23, 33, 43, and 53, shifting your resource usage away from other system tasks that trigger on the hour.
Will timezone shifts or Daylight Saving Time affect this 10-minute schedule?
Because the interval is highly frequent and hourly, Daylight Saving Time transitions will not cause missed intervals, though the system clock offset change might briefly make one interval appear to take 70 minutes or run instantly. Running your system cron daemon in UTC is highly recommended to guarantee absolute consistency.
How should I handle logging for a job that runs this frequently?
Running 144 times a day can generate significant log volume. Implement log rotation with compression, avoid verbose debug logging in production, and redirect standard output to structured JSON logs. Ensure you include a unique execution ID for each run to facilitate easy log aggregation and debugging.
Is this cadence suitable for polling external APIs?
Yes, a 10-minute interval is highly suitable for non-realtime API polling. However, you must handle network timeouts gracefully. Set explicit connection and read timeouts (e.g., 30 seconds) in your HTTP client to prevent hanging sockets from blocking future scheduled runs.
* Explore
Related expressions you might need
Last verified: