Setting up cron jobs in cPanel

A cron job is a scheduled task that runs automatically on your server at a fixed interval — every minute, every hour, every Sunday at 3 AM, or any other schedule you can express. cPanel makes setting them up straightforward without ever touching the command line. This article covers the syntax, the common use cases, and the gotchas.

Where to find cron jobs in cPanel

  1. Log in to cPanel.
  2. Under Advanced, click Cron Jobs.
  3. You will see two sections: Cron Email at the top, and Add New Cron Job in the middle.

Set up email notifications first

Before adding any cron job, set the Cron Email address. cPanel will email you the output of every cron run. By default this is too noisy — most cron jobs produce some output even on success. Two options:

  • Set the email to a real address you check, then add > /dev/null 2>&1 to the end of each cron command (suppresses both stdout and stderr).
  • Or, leave the field blank to disable email entirely.

Most experienced users go with the second approach and add their own logging inside the script.

Cron syntax: 5 fields

Cron schedules use 5 space-separated fields:

* * * * * command-to-run
| | | | |
| | | | +-- Day of week (0-6, Sunday=0)
| | | +---- Month (1-12)
| | +------ Day of month (1-31)
| +-------- Hour (0-23)
+---------- Minute (0-59)

Each field accepts:

  • A specific number: 5 means at minute 5, hour 5, etc.
  • An asterisk (*): means "every" — * * * * * runs every minute.
  • A range: 1-5 means 1 through 5.
  • A list: 1,15,30 means at those exact values.
  • A step: */5 means every 5 (every 5 minutes, every 5 hours, etc.).

Common schedules

ScheduleCron expression
Every minute* * * * *
Every 5 minutes*/5 * * * *
Every hour at :000 * * * *
Every day at 3 AM0 3 * * *
Every Sunday at 4 AM0 4 * * 0
1st of every month at midnight0 0 1 * *
Weekdays at 9 AM0 9 * * 1-5

cPanel also offers a Common Settings dropdown for these without having to remember the syntax.

Adding a cron job

  1. In the Add New Cron Job section, pick a Common Setting or fill in each of the 5 fields manually.
  2. Enter the command in the Command field.
  3. Click Add New Cron Job.

Common cron use cases

WordPress: replacing wp-cron.php with a real cron

By default, WordPress runs its scheduled tasks (publishing scheduled posts, sending notifications, plugin maintenance) via wp-cron.php, which fires on every page load. On low-traffic sites scheduled tasks miss; on high-traffic sites it slows page loads. The fix:

  1. Add this cron job: */15 * * * * wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
  2. Edit your wp-config.php and add: define('DISABLE_WP_CRON', true);

Now WordPress scheduled tasks run reliably every 15 minutes regardless of traffic.

Database backups

To dump a MySQL database to a file every night at 2 AM:

0 2 * * * /usr/bin/mysqldump -u dbuser -pPASSWORD dbname > /home/USERNAME/backups/db-$(date +\%Y\%m\%d).sql 2>/dev/null

Note: the % character must be escaped as \% in cron syntax. Replace USERNAME, dbuser, dbname, and PASSWORD with your values.

Periodic Laravel/PHP scripts

Most modern PHP frameworks expect a single cron entry that fires their internal scheduler every minute:

* * * * * /usr/local/bin/php /home/USERNAME/public_html/artisan schedule:run >> /dev/null 2>&1

Testing your cron job

To verify a cron job runs without waiting for its next scheduled time, just run the command directly via SSH or via cPanel's Terminal feature. If it fails interactively, it will fail in cron too. Cron failures are usually:

  • Wrong path to the executable: use full paths like /usr/local/bin/php not just php.
  • Wrong working directory: cron runs in your home directory by default. Use absolute paths to scripts and data files, or cd first.
  • Missing environment variables: cron has a minimal environment. If your script needs PATH or other vars, set them inside the script.

Common pitfalls

  • Excessive frequency. Cron jobs running every minute can get you firewalled if they're hitting your own site over HTTP. Once every 5 minutes is plenty for most use cases.
  • Long-running jobs overlapping. If a job takes longer than its schedule interval, two copies can run simultaneously. Wrap with flock if this is a concern: flock -n /tmp/myjob.lock command
  • Output filling your mailbox. Set Cron Email to blank, or redirect output as shown above.
  • Quotas. Cron jobs that write files count against your disk quota. Make sure your job doesn't silently fail because the disk is full.
  • cron, scheduled tasks, cPanel, WordPress, automation
  • 0 משתמשים שמצאו מאמר זה מועיל
?האם התשובה שקיבלתם הייתה מועילה

מאמרים קשורים

Nameservers

The nameservers to use for our webhosting services are below: all1.dnsroundrobin.net...

Setting up Dynamic DNS in cPanel

cPanel includes a built-in Dynamic DNS feature that automatically keeps an A record pointed at a...

Setting up Cloudflare with cPanel: the right way

Cloudflare is a free CDN and DDoS-protection service that sits in front of your ipxcore cPanel...

Speeding up WordPress on cPanel hosting

A slow WordPress site costs you visitors, conversions, and search rankings — Google has...

How to migrate your website to ipxcore from another host

Migrating an existing website to ipxcore is a process we've helped thousands of customers...