Cron Job Builder

Build and test cron expressions with our visual editor. Generate cron schedules with human-readable descriptions and preview next execution times.

Quick Presets

Manual Configuration

Syntax: Use * for any value, numbers for specific values, */N for intervals, or comma-separated values (e.g., 1,15,30)

Command Templates

Command

Generated Cron Expression

0 3 * * *
0 3 * * *
Runs daily at 3:00

How to Install This Cron Job

1. Open Crontab Editor

crontab -e

2. Add Your Cron Job

Paste the full cron job expression at the end of the file

3. Save and Exit

Save the file (usually Ctrl+O, then Enter, then Ctrl+X for nano)

4. Verify Installation

crontab -l

Features

Quick Presets

12 common cron patterns ready to use - from every minute to yearly schedules

Manual Configuration

Full control with individual field editing for custom schedules

Next Run Preview

See the next 5 execution times to verify your schedule

Understanding Cron Syntax

Cron Expression Format

A cron expression consists of five fields that define when a job should run:

* * * * * command
│ │ │ │ │
│ │ │ │ └─── Day of Week (0-6, Sunday=0)
│ │ │ └───── Month (1-12)
│ │ └─────── Day of Month (1-31)
│ └───────── Hour (0-23)
└─────────── Minute (0-59)

Special Characters

*

Asterisk

Matches any value (every minute, hour, day, etc.)

,

Comma

Separates multiple values (e.g., 1,15,30 for specific times)

-

Hyphen

Defines a range (e.g., 1-5 for Monday through Friday)

/

Slash

Defines step values (e.g., */5 for every 5 units)

Common Examples

0 * * * *
Run at the start of every hour
0 0 * * *
Run daily at midnight
0 0 * * 0
Run weekly on Sunday at midnight
0 0 1 * *
Run monthly on the 1st at midnight
*/15 * * * *
Run every 15 minutes
0 9-17 * * 1-5
Run every hour from 9 AM to 5 PM, Monday to Friday

Common Use Cases

💾 Database Backups

Schedule daily database backups at 2 AM when traffic is low

0 2 * * * /usr/local/bin/backup.sh

🗑️ Cache Clearing

Clear application cache every 6 hours to free up disk space

0 */6 * * * rm -rf /var/cache/*

📊 Log Rotation

Rotate and compress logs weekly to manage disk usage

0 0 * * 0 /usr/sbin/logrotate

⬆️ System Updates

Check for and install security updates every Sunday at 3 AM

0 3 * * 0 apt-get update && apt-get upgrade -y

📧 Email Reports

Send weekly server status reports every Monday at 8 AM

0 8 * * 1 /usr/local/bin/report.sh

🔄 Service Restarts

Restart application server daily to prevent memory leaks

0 4 * * * systemctl restart app.service

Best Practices

1

Use Absolute Paths

Always use full paths for commands and scripts to avoid PATH issues. Example: /usr/bin/python instead of python

2

Redirect Output

Redirect output to log files for debugging. Example: script.sh >> /var/log/cron.log 2>&1

3

Test Commands First

Always test your command manually before adding it to crontab to ensure it works correctly

4

Avoid Overlapping Jobs

Use locking mechanisms to prevent multiple instances of the same job running simultaneously

5

Set Environment Variables

Define necessary environment variables at the top of your crontab file or within your script

6

Monitor Execution

Check system logs regularly to ensure cron jobs are running as expected: grep CRON /var/log/syslog

Troubleshooting

Cron Job Not Running?

  • Check if cron service is running: systemctl status cron
  • Verify crontab syntax: crontab -l
  • Check system logs for errors: grep CRON /var/log/syslog
  • Ensure script has execute permissions: chmod +x script.sh

Command Works Manually But Not in Cron?

  • Cron runs with minimal environment - specify full paths to binaries
  • Set PATH at top of crontab: PATH=/usr/local/bin:/usr/bin:/bin
  • Source required environment in your script