Preskoči na sadržaj
BeoHosting
BeoHosting

8 min

How to Set Up a Cron Job

cPanel Cron Jobs, crontab syntax, wp-cron and PHP automation.

BeoHosting Tim

10+ godina iskustva — Stručnjaci za web hosting i infrastrukturu

Poslednje ažurirano:

Cron jobs run scripts on a schedule — every minute, hourly, daily, or on specific days. They power backups, email queues, WordPress scheduled posts, cache cleanup and countless other automation tasks. This guide shows how to add a cron job in cPanel, how the crontab syntax works (* * * * *), and how to replace WordPress's unreliable wp-cron with a real server cron.

How to Set Up a Cron Job

1

Open Cron Jobs in cPanel

cPanel → Advanced → Cron Jobs. You see existing crons and a form to add new ones. cPanel hosts (BeoHosting included) allow unlimited crons on most plans.

2

Understand the cron syntax

Five fields: minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (0-6, Sun=0). * means "every". Examples: "0 * * * *" = every hour at minute 0. "*/5 * * * *" = every 5 minutes.

3

Add a cron via the cPanel shortcuts

Use the "Common Settings" dropdown — "Once per hour", "Once per day" pre-fill syntax. Then type the command, e.g. /usr/local/bin/php /home/user/public_html/script.php.

4

Replace WP-Cron with a real cron

WordPress's default wp-cron runs on every page visit — unreliable. Disable it: add define('DISABLE_WP_CRON', true); to wp-config.php. Then add cron: */5 * * * * curl -s https://yourdomain.com/wp-cron.php?doing_wp_cron > /dev/null.

5

Common cron tasks

Backups: 0 3 * * * /path/backup.sh. Send pending emails: */10 * * * * /usr/local/bin/php /path/send-mail.php. Clear cache: 0 4 * * * /path/clear-cache.sh. Sync product feed: 0 */6 * * * /path/sync-feed.php.

6

Email notifications and debugging

cPanel Cron Jobs has an Email field — set it to receive output. To suppress emails on success: add > /dev/null 2>&1. To log to a file: > /home/user/cron.log 2>&1.

Spremni da pokrenete svoj sajt?

SSL zaštita
Brzina
24/7 podrška

Pridružite se 4.000+ zadovoljnih korisnika. Besplatna migracija i 15 dana garancije povrata novca.

15 dana garancija povrata novca
Besplatna migracija15 dana garancija24/7 podrška

FAQ

Odgovori na najčešća pitanja o našim uslugama.

Minimum 1 minute on BeoHosting. Some shared hosts limit to 5 or 15 minutes minimum. For high-frequency tasks, consider a worker/queue instead of cron.

Check command path is absolute (/usr/local/bin/php, not just php). Check file permissions (chmod +x for shell scripts). Check the email output or /var/log/cron. Add 2>&1 > /tmp/cron.log to capture errors.

Server cron is more reliable, faster and lower overhead. WP-Cron only runs when someone visits the site — bad for low-traffic sites. Always disable WP-Cron and use a real cron in production.

On shared hosting, no — crons run as your cPanel user. On VPS/dedicated, edit /etc/crontab or use sudo crontab -u username -e.

Add the line define('DISABLE_WP_CRON', true); to your wp-config.php file (before the "That's all, stop editing!" line). Then create a Cron Job in cPanel with the command: /usr/local/bin/php /home/username/public_html/wp-cron.php and set it to "Once Per Fifteen Minutes". This is more reliable because WordPress cron by default relies on site visits — if there are no visitors, scheduled tasks do not run.

Naše garancije za vaš mir

Zaštićeni ste sa svake strane

15 dana garancije

Vraćamo novac bez pitanja u prvih 15 dana.

Besplatna migracija

Mi prebacimo vaš sajt bez prekida — vi ništa ne radite.

24/7 podrška

Naši stručnjaci su tu 24/7 kroz tikete i live chat.