Skip to content
BeoHosting
BeoHosting

8 min

How to Set Up a Cron Job

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

BeoHosting Team

10+ years of experience — Web hosting and infrastructure specialists

Last updated:

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.

Ready to launch your website?

SSL protection
Speed
24/7 support

Join 4,000+ satisfied customers. Free migration and 15-day money-back guarantee.

15-day money-back guarantee
Free migration15-day guarantee24/7 support

FAQ

Answers to the most common questions about our services.

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.

Our guarantees for your peace of mind

Protected from every angle

15-day guarantee

We refund without questions in the first 15 days.

Free migration

We migrate your site with no downtime — you do nothing.

24/7 support

Our experts are here 24/7 via tickets and live chat.