Back to blog
DevOps August 13, 2026

What is a Cron Job? The Ultimate Guide to Scheduled Tasks

What is a Cron Job? The Ultimate Guide to Scheduled Tasks

In modern web development and system administration, many tasks need to run repeatedly at scheduled times. Instead of developers triggering database backups, cleanup scripts, or billing charges manually, servers automate these actions using a system utility called a cron job.

Understanding what a cron job is, how to write the configuration syntax, and how to verify that scheduled tasks execute successfully is essential for any backend developer or SRE.


1. What is a Cron Job?

A cron job is a time-based task scheduler in Unix-like operating systems (including Linux and macOS). The system daemon responsible for running these background tasks is named cron.

The scheduler reads configuration tables called crontabs (short for "cron tables"), which specify which command to run and exactly when to run it.

Common use cases for cron jobs include:

  • Database Backups: Saving database dumps every night at midnight.
  • Log Rotation: Compressing and archiving server logs weekly to prevent disk space saturation.
  • Billing Actions: Renewing subscriptions or processing credit card payments monthly.
  • Caching Updates: Fetching external API data and updating local caches every hour.

2. Understanding Cron Expression Syntax

Every cron job is defined by a line in a crontab file containing a cron expression followed by the target command. A standard cron expression consists of five fields separated by spaces:

┌─────────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌─────────── day of the month (1 - 31)
│ │ │ ┌───────── month (1 - 12)
│ │ │ │ ┌─────── day of the week (0 - 6, Sunday is 0)
│ │ │ │ │
* * * * *  /path/to/command.sh

Common Operator Symbols

  • * (Asterisk): Represents "all values". For example, * in the hour field means "run every hour".
  • , (Comma): Defines a list of specific values. For example, 1,15,30 in the minute field.
  • - (Hyphen): Defines a range of values. For example, 1-5 in the day-of-week field means Monday through Friday.
  • / (Slash): Defines step intervals. For example, */15 in the minute field means "every 15 minutes".

3. Practical Cron Expression Examples

  • Run every minute: * * * * *
  • Run every day at midnight: 0 0 * * *
  • Run every Sunday at 3:30 AM: 30 3 * * 0
  • Run every 15 minutes during business hours (9 AM - 5 PM, Mon-Fri): */15 9-17 * * 1-5

4. Setting Up and Managing Crontabs

To view or edit cron jobs on Linux or macOS, use your terminal:

  • Edit your crontab: crontab -e
  • List active cron jobs: crontab -l
  • Remove all cron jobs: crontab -r

[!TIP] Use Absolute Paths: The cron daemon runs in a restricted shell environment with a minimal path configuration. Always use absolute paths for both commands and scripts (e.g., use /usr/bin/curl instead of just curl) to prevent "Command Not Found" execution crashes.


5. Free Tools to Build and Translate Cron Schedules

Writing raw cron strings can be error-prone. To help you build and verify your cron expressions, we built two free interactive tools directly inside Pingzo:

  • Cron Expression Builder: An interactive UI tool to generate valid cron strings by selecting intervals via sliders and dropdowns.
  • Cron Translator: Paste any cron string (e.g., 30 2 * * 1) and instantly translate it into clear, human-readable English.

6. How to Monitor Cron Jobs (Heartbeat Monitoring)

The primary downside of cron jobs is that they fail silently. If a background database backup script crashes due to connection timeouts, the script exits silently.

Standard external uptime checkers cannot detect this because your web server is still technically online. To monitor background scripts, SREs use Heartbeat Checks:

  1. Generate a Pingzo Heartbeat URL: Pingzo provides a unique URL endpoint for your task.
  2. Ping Upon Completion: Append a ping check to the end of your scheduled script:
    /path/to/backup.sh && curl -fsS https://ping.pingzoapp.com/hz_cron_abc
    
  3. Snooze & Alert Thresholds: If Pingzo does not receive a ping check within your scheduled window (plus a custom grace period), it immediately dispatches an alert to your WhatsApp, Slack, or Telegram channels.
Try Pingzo Free

Know before your users do

Connect official WhatsApp notification channels, Discord webhooks, Telegram bots, and public status pages. Start in 30 seconds.

Create Free Monitor