Schedule Tasks Every Hour on the Hour | CronBase
0 */1 * * * At the start of every hour, every day of the year.
The `0 */1 * * *` cron expression executes a task exactly at the beginning of every hour, at minute zero. It is widely used for routine maintenance, synchronized data ingestion, log rotation, and transactional health checks that require frequent, consistent intervals without overwhelming system resources.
- Minute
- 0
- Hour
- */1
- Day of Month
- *
- Month
- *
- Day of Week
- *
Next 5 Runs
- in 36m 46s
- in 1h 36m
- in 2h 36m
- in 3h 36m
- in 4h 36m
* Tools
Code & Implementations
#!/usr/bin/env bash
set -euo pipefail
LOCKFILE="/var/lock/hourly_sync_job.lock"
exec 9>"$LOCKFILE"
if ! flock -n 9; then
echo "Error: Another instance of the hourly job is already running." >&2
exit 1
fi
echo "Starting hourly maintenance task..."
/usr/local/bin/perform-sync.sh
echo "Hourly task completed successfully." › Setup notes
Save this script to /usr/local/bin/hourly-task.sh, make it executable with chmod +x, and add '0 */1 * * * /usr/local/bin/hourly-task.sh' to your crontab using crontab -e.
const cron = require('node-cron');
const { exec } = require('child_process');
// Schedule task to run at minute 0 of every hour
cron.schedule('0 */1 * * *', () => {
console.log(`[${new Date().toISOString()}] Starting hourly database cleanup...`);
exec('/usr/bin/node /app/cleanup.js', (error, stdout, stderr) => {
if (error) {
console.error(`Execution error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Stderr output: ${stderr}`);
}
console.log(`Stdout: ${stdout}`);
});
}); › Setup notes
Install the node-cron dependency via npm install node-cron, then run this script using node scheduler.js to start the persistent daemon process.
import logging
from apscheduler.schedulers.blocking import BlockingScheduler
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
scheduler = BlockingScheduler()
# Run hourly at minute 0
@scheduler.scheduled_job('cron', minute=0, hour='*')
def hourly_task():
logging.info("Starting hourly log analysis pipeline...")
try:
# Core business logic execution
pass
except Exception as e:
logging.error(f"Task failed: {e}", exc_info=True)
if __name__ == "__main__":
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass › Setup notes
Install apscheduler using pip install apscheduler, and run the script as a daemon. It handles internal cron-like scheduling natively.
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/robfig/cron/v3"
)
func main() {
logger := log.New(os.Stdout, "CRON: ", log.LstdFlags|log.Lshortfile)
c := cron.New(cron.WithParser(cron.NewParser(
cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor,
)))
_, err := c.AddFunc("0 */1 * * *", func() {
logger.Println("Executing hourly health check routine...")
// Insert execution logic here
})
if err != nil {
logger.Fatalf("Error scheduling job: %v", err)
}
c.Start()
logger.Println("Cron scheduler started successfully")
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
<-sigChan
c.Stop()
} › Setup notes
Run go get github.com/robfig/cron/v3 to fetch the dependency, then compile and execute this application as a background service.
package com.example.cron;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.logging.Logger;
import java.util.logging.Level;
@Component
public class HourlyJobScheduler {
private static final Logger LOGGER = Logger.getLogger(HourlyJobScheduler.class.getName());
// Spring cron expression requires 6 fields (second, minute, hour, day, month, weekday)
@Scheduled(cron = "0 0 * * * *")
public void executeHourlyTask() {
LOGGER.info("Starting hourly transactional reconciliation...");
try {
// Task execution logic
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error during hourly task execution", e);
}
}
} › Setup notes
Ensure @EnableScheduling is declared on your main Spring Boot application class. This component will automatically be scanned and run.
apiVersion: batch/v1
kind: CronJob
metadata:
name: hourly-data-sync
namespace: default
spec:
schedule: "0 */1 * * *"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: worker
image: alpine:latest
command: ["/bin/sh", "-c", "echo 'Starting sync...'; sleep 10; echo 'Sync finished.'"]
restartPolicy: OnFailure › Setup notes
Save this configuration to hourly-cronjob.yaml and apply it to your cluster using kubectl apply -f hourly-cronjob.yaml.
Last verified:
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.
cron(0 */1 * * ? *) Systemd Timer
OnCalendar*-*-* 00/1:00:00
[Unit]
Description=Timer for cron expression: 0 */1 * * *
[Timer]
OnCalendar=*-*-* 00/1:00:00
Persistent=true
[Install]
WantedBy=timers.target
Last verified:
Frequently Asked Questions
What is the difference between `0 */1 * * *` and `0 * * * *`?
There is no functional difference; both expressions execute at minute zero of every hour. The `*/1` syntax explicitly denotes a step interval of one hour, while the bare asterisk implicitly means every hour. Most modern cron daemons optimize both to the exact same execution pattern.
How can I prevent multiple hourly executions from overlapping if a task runs long?
You should implement a locking mechanism. In Bash, use the `flock` utility to wrap your script. In application code, use distributed lock managers like Redis (Redlock) or database-backed locks to ensure only one instance of the hourly task runs at any given time.
How do Daylight Saving Time (DST) changes affect this hourly cron schedule?
During the autumn transition (clocks move back), the hour of the shift repeats, potentially executing your job twice. In spring (clocks move forward), an hour is skipped, meaning your job may skip a run. To avoid this, configure your cron daemon or system timezone to use Coordinated Universal Time (UTC).
Can I stagger this job to avoid the thundering herd problem on my database?
Yes, running tasks exactly at minute zero can overload shared services if many systems do the same. You can stagger the execution by changing the minute field to a specific offset, such as `15 */1 * * *` to run at fifteen minutes past every hour instead of on the hour.
How should I monitor that my hourly cron job actually executed successfully?
Since hourly jobs run frequently, passive monitoring is highly effective. Implement a heartbeat monitor (e.g., sending a curl request to an external monitoring service at the end of the script). If the service doesn't receive a ping within 65 minutes, it triggers an alert.
* Explore
Related expressions you might need
Last verified: