Cron Job Every 5 Minutes: Complete Setup Guide for 2026

Cron Job Every 5 Minutes: Complete Setup Guide for 2026

A cron job every 5 minutes runs a scheduled task repeatedly at 5-minute intervals using the cron syntax */5 * * * * in your crontab file. This automation tool executes scripts, backups, or maintenance tasks consistently without manual intervention, making it essential for DevOps and server management workflows.

What Is a Cron Job Every 5 Minutes?

Cron is a time-based job scheduler built into Unix-like operating systems. It reads configuration files called crontabs and executes commands at specified times or intervals. When you schedule a task every 5 minutes, you’re telling the cron daemon to wake up and run your script twelve times per hour, every hour, around the clock.

This Linux cron 5 minute frequency is one of the most commonly used intervals in production environments. It strikes a practical balance — frequent enough to catch errors quickly or process incoming data promptly, but not so aggressive that it hammers your server resources with near-constant execution.

Common reasons engineers set up a 5-minute schedule task include:

  • Polling an external API for new data
  • Clearing application cache automatically
  • Running health checks on services or endpoints
  • Processing queued jobs in batches
  • Syncing files between directories or servers
  • Sending queued email notifications

How to Set Up a Cron Job for 5-Minute Intervals

How do I create a cron job that runs every 5 minutes?

Creating a cron job that runs every 5 minutes takes less than two minutes once you know the steps. Open your terminal and follow this process:

Step 1: Open your crontab editor

crontab -e

This opens the crontab file for the current user in your default text editor. If it’s your first time, the system may prompt you to choose an editor — nano is the most beginner-friendly option.

Step 2: Add your cron expression

Add a new line using the 5-minute interval cron expression followed by your command:

*/5 * * * * /usr/bin/php /var/www/html/cron.php

Always use absolute paths for both the executable and the script. Cron runs in a minimal environment and won’t resolve relative paths or user-defined aliases the way your shell session does.

Step 3: Save and verify

Save the file and exit. Verify your new entry loaded correctly with:

crontab -l

Your scheduled task will begin running at the next 5-minute mark on the system clock — for example, at :00, :05, :10, and so on.

Step 4: Redirect output for logging

By default, cron sends output to your system mail. Redirect it to a log file instead:

*/5 * * * * /usr/bin/php /var/www/html/cron.php >> /var/log/mycron.log 2>&1

Cron Syntax Explained: The */5 Expression

What does */5 mean in a cron expression?

A full cron expression contains five fields separated by spaces. Reading left to right, those fields represent: minute, hour, day of month, month, and day of week. The cron expression 5 minute interval looks like this:

*/5 * * * * command

The * symbol means “every,” and the /5 is a step value meaning “every 5th.” Combined as */5 in the minute field, it translates literally to: “at every 5th minute of every hour of every day.” The remaining four asterisks mean “any hour, any day, any month, any weekday.”

Here’s a quick reference for related intervals using the same step syntax:

Expression Meaning
*/5 * * * * Every 5 minutes
*/10 * * * * Every 10 minutes
*/15 * * * * Every 15 minutes
0 */2 * * * Every 2 hours
*/5 9-17 * * 1-5 Every 5 min, business hours weekdays only

If you need to validate or build cron expressions quickly without memorizing syntax, the cron expression generator on DevUtilityPro lets you configure your schedule visually and instantly see the resulting expression.

Practical Examples and Use Cases

Understanding the cron expression is only half the picture. Here are real-world implementations engineers rely on for their 5-minute scheduled tasks:

Database backup script:

*/5 * * * * /home/ubuntu/scripts/db_backup.sh >> /var/log/db_backup.log 2>&1

Python script for API polling:

*/5 * * * * /usr/bin/python3 /opt/app/poll_api.py

Clearing a temporary directory:

*/5 * * * * find /tmp/uploads -type f -mmin +30 -delete

WordPress scheduled task trigger (common for WP-Cron replacement):

*/5 * * * * wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

This last example is particularly valuable for WordPress developers. Replacing WP-Cron’s default behavior with a real system cron at 5-minute intervals makes scheduled posts, email queues, and plugin tasks far more reliable.

For teams calculating server costs around jobs like these — especially when running them across multiple instances — tools like the server cost calculator help you estimate the resource overhead before scaling.

Troubleshooting Common Cron Job Issues

Even with the correct cron expression 5 minute interval in place, jobs sometimes fail silently. Here are the most frequent problems and how to fix them:

Script doesn’t run at all: Check that the cron daemon is active with systemctl status cron (Debian/Ubuntu) or systemctl status crond (CentOS/RHEL). Confirm file permissions allow execution with

Recommended Resources:

  • AWS Systems Manager (OpsWorks) — Ideal for managing scheduled tasks and cron jobs across AWS infrastructure at scale, perfect for DevOps professionals implementing automation workflows.
  • Cloudflare Workers Cron Triggers — Serverless alternative for scheduling tasks without managing cron directly, great for developers wanting simpler scheduled job management in the cloud.
  • Datadog Monitoring & Alerting — Essential for monitoring cron job execution, performance, and failures – helps DevOps teams track and debug scheduled tasks in production environments.

Related: How to Write a Cron Job: Syntax and Examples

Leave a Comment

Your email address will not be published. Required fields are marked *

Developer Tools Assistant
Powered by AI · Free
···

Need Fast, Reliable Hosting for Your Dev Projects?

Cloudways managed cloud hosting — no server management, scales instantly.

See Cloudways Pricing →
Scroll to Top
⚡ Sponsored

WP Rocket — The #1 WordPress Cache Plugin

Trusted by 5M+ websites. Boosts Core Web Vitals and page speed in minutes. Single $59 · Growth $119 · Multi $299+

Get WP Rocket →

Affiliate partner — we may earn a commission at no extra cost to you.

⚡ Sponsored

Quickfire Cache — Lightweight WordPress Caching

Cut WordPress page load times by up to 60%. Activates in minutes. No bloat, no config headaches. From $79/year.

Get Quickfire Cache →

Affiliate partner — we may earn a commission at no extra cost to you.