Execute Automation Tasks Every Minute | CronBase
*/1 * * * * Every single minute, endlessly throughout the day, every day of the year.
This cron expression schedules a command to execute once every single minute of every hour, day, month, and day of the week. It represents the highest default frequency available in standard cron engines, commonly utilized for real-time monitoring, rapid queue processing, health checks, and high-frequency data ingestion pipelines.
- Minute
- */1
- Hour
- *
- Day of Month
- *
- Month
- *
- Day of Week
- *
Next 5 Runs
- in 38s
- in 1m 38s
- in 2m 38s
- in 3m 38s
- in 4m 38s
* Tools
Code & Implementations
#!/usr/bin/env bash
# Prevent overlapping executions using flock
LOCKFILE="/var/lock/my_minute_job.lock"
exec 9>"$LOCKFILE"
if ! flock -n 9; then
echo "Job is already running. Exiting to prevent overlap."
exit 1
fi
echo "Starting minute-by-minute execution..."
curl -f -s https://api.example.com/health || echo "Health check failed" › Setup notes
Save this script to your server, make it executable with chmod +x, and configure standard crontab to point to its path.
const cron = require('node-cron');
let isRunning = false;
cron.schedule('*/1 * * * *', async () => {
if (isRunning) {
console.warn('Previous execution still active. Skipping run.');
return;
}
isRunning = true;
try {
console.log('Executing high-frequency polling task...');
await new Promise(resolve => setTimeout(resolve, 5000));
} catch (error) {
console.error('Task failed:', error);
} finally {
isRunning = false;
}
}); › Setup notes
Install node-cron via npm, run the script as a daemon using pm2 or systemd to ensure continuous execution.
import os
import sys
import fcntl
lock_file_path = '/tmp/my_minute_task.lock'
lock_file = open(lock_file_path, 'w')
try:
fcntl.flock(lock_file, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
print('Another instance of this task is running. Exiting.')
sys.exit(0)
def main():
print('Running scheduled database cleanup and queue processing...')
if __name__ == '__main__':
main() › Setup notes
Schedule this script in your system crontab. The fcntl locking mechanism ensures only one instance runs at a time.
package main
import (
"context"
"log"
"sync/atomic"
"time"
"github.com/robfig/cron/v3"
)
func main() {
c := cron.New()
var running int32
_, err := c.AddFunc("*/1 * * * *", func() {
if !atomic.CompareAndSwapInt32(&running, 0, 1) {
log.Println("Previous job run still in progress, skipping.")
return
}
defer atomic.StoreInt32(&running, 0)
log.Println("Starting every-minute execution pipeline...")
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Second)
defer cancel()
_ = ctx
})
if err != nil {
log.Fatalf("Error scheduling job: %v", err)
}
c.Start()
select {}
} › Setup notes
Import robfig/cron, build the binary, and run it as a persistent service inside your environment.
package com.example.cron;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.concurrent.atomic.AtomicBoolean;
@Component
public class MinuteTaskScheduler {
private final AtomicBoolean isRunning = new AtomicBoolean(false);
@Scheduled(cron = "0 */1 * * * *")
public void executeTask() {
if (!isRunning.compareAndSet(false, true)) {
System.out.println("Execution skipped: Previous task is still running.");
return;
}
try {
System.out.println("Executing system health and metric collection...");
} finally {
isRunning.set(false);
}
}
} › Setup notes
Enable scheduling in your Spring Boot application by adding @EnableScheduling to your main configuration class.
apiVersion: batch/v1
kind: CronJob
metadata:
name: every-minute-worker
namespace: default
spec:
schedule: "*/1 * * * *"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: worker
image: busybox:1.35
command: ["sh", "-c", "echo 'Running high-frequency queue process' && sleep 10"]
restartPolicy: OnFailure › Setup notes
Apply this manifest to your cluster. The concurrencyPolicy: Forbid field is critical to prevent overlapping Pods.
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(*/1 * * * ? *) Systemd Timer
OnCalendar*-*-* *:00/1:00
[Unit]
Description=Timer for cron expression: */1 * * * *
[Timer]
OnCalendar=*-*-* *:00/1:00
Persistent=true
[Install]
WantedBy=timers.target
Last verified:
Frequently Asked Questions
What happens if a job takes longer than one minute?
In a standard setup, a new instance will start anyway, potentially leading to race conditions or server overload. It is highly recommended to use a lock mechanism like flock, Redis lock, or Kubernetes' Forbid policy to prevent overlapping.
Does standard cron support sub-minute execution?
No, standard Unix cron's minimum resolution is one minute. If you need sub-minute execution (e.g., every 30 seconds), you must use a systemd service with a timer, or run a persistent background daemon that sleeps inside a loop.
How does timezone change affect an every-minute cron job?
Timezone changes (like Daylight Saving Time shifts) do not affect the frequency of an every-minute cron job. It will continue to execute exactly once every 60 seconds regardless of the clock shifting forward or backward.
Will this high frequency cause high CPU overhead?
The cron daemon itself consumes negligible CPU to trigger the task. However, the script or application being executed can cause high system load if it initializes heavy frameworks, database connections, or VM runtimes every single minute.
How do I monitor if my minute-by-minute cron job fails?
Since it runs frequently, traditional log checking is tedious. Implement a dead-man's snitch (e.g., Healthchecks.io) that expects a ping every minute, or route stderr to an enterprise alerting tool like Sentry or PagerDuty.
* Explore
Related expressions you might need
Last verified: