⏰
Hosting

Complete Cron Job Guide: Scheduling Automatic Tasks

24.01.2026
← All articles

Cron is the system for scheduling automated tasks on Unix and Linux servers. Created by Brian Kernighan at AT&T Bell Labs in 1975. Cron runs every minute and checks its schedule — if a scheduled time matches it runs the corresponding script. You'll need this for site backups, email sending, database cleanup, and similar recurring tasks.

Cron syntax

Cron job syntax has five fields: minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-7, both 0 and 7 = Sunday), then the command to run.

Examples: * * * * * /path/to/script.sh — every minute; 0 * * * * /path/to/script.sh — at the top of every hour; 0 0 * * * /path/to/script.sh — every day at midnight; 0 0 * * 0 /path/to/script.sh — every Sunday at midnight; */5 * * * * /path/to/script.sh — every 5 minutes.

Adding a cron job in cPanel

cPanel → Cron Jobs → "Add New Cron Job". Pick a preset under Common Settings or set a custom time. Enter the command to run in the Command field. Example: WordPress wp-cron.php every 15 minutes: */15 * * * * /usr/local/bin/php /home/user/public_html/wp-cron.php

Real examples

Automate WordPress wp-cron — native WordPress cron runs on every page load (slow). Better to run it via real cron every 15 minutes. First add to wp-config.php: define('DISABLE_WP_CRON', true);, then create the cron.

Daily database backup — 0 2 * * * mysqldump -u dbuser -pPASSWORD dbname | gzip > /home/user/backups/db_$(date +\%Y\%m\%d).sql.gz. The % must be escaped as \%.

Send a weekly email report on Monday morning: 0 9 * * 1 /usr/local/bin/php /home/user/scripts/weekly_report.php.

Clean log files on the 1st of every month: 0 0 1 * * find /home/user/logs -name "*.log" -mtime +30 -delete.

Debugging

If cron doesn't run, common causes: (1) Path issue — incomplete script path; (2) Permission issue — script doesn't have execute permission (chmod +x); (3) Missing shebang — no #!/bin/bash or #!/usr/bin/php at the top; (4) Environment — cron's environment differs from shell, $PATH and others are different.

For debugging, redirect output to a log file: * * * * * /path/to/script.sh > /home/user/cron.log 2>&1.

Sayt.uz practice

Cron jobs are enabled by default on Sayt.uz hosting plans. Basic Hosting has 5 cron jobs; Pro Hosting unlimited. 67% of clients use at least one cron. Most common uses: WordPress wp-cron (47%), database backup (32%), email/Telegram notifications (28%), log cleanup (19%). Tip: always write cron scripts with absolute paths (/home/user/script.sh, not ./script.sh) — this is the single biggest source of errors.

Related articles

🛒 OpenCart hosting settings: the essential steps after installation 📰 Hosting for DLE (DataLife Engine): setup, migration and security 💰 Cutting Hosting Costs Without Sacrificing Quality 🏬 1C-Bitrix hosting requirements: PHP, MySQL, agents and 1C exchange
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓