UnderHost
Knowledgebase Docs

Cron jobs in cPanel: schedule PHP and maintenance

Create cron jobs in cPanel, understand cron timing syntax, run PHP scripts safely, control email output, and debug jobs that do not run as expected.

On this page

Cron jobs run commands automatically on a schedule. In cPanel, they are commonly used for application maintenance, queue processing, report generation, cache cleanup, and replacing WordPress pseudo-cron with a real scheduled task.

When to use cron

  • Run a PHP maintenance script every hour or every day.
  • Trigger WordPress wp-cron.php on a reliable schedule.
  • Process email queues, invoices, imports, or cleanup tasks.
  • Generate reports outside peak visitor hours.

Avoid running jobs every minute unless the application truly requires it. Frequent jobs can create unnecessary CPU and process usage on shared hosting.

Add a cron job in cPanel

  1. Log in to cPanel.
  2. Open Advanced and choose Cron Jobs.
  3. Set the cron email address, or leave output redirected to a log file instead.
  4. Choose a common schedule or enter custom timing values.
  5. Enter the command.
  6. Click Add New Cron Job.

Timing syntax

# minute hour day-of-month month day-of-week command
0 * * * *        command   # every hour
0 2 * * *        command   # every day at 2:00
0 2 * * 0        command   # every Sunday at 2:00
*/15 * * * *     command   # every 15 minutes

cPanel's common settings dropdown is safer if you are not comfortable writing cron syntax manually.

Run PHP scripts

Use the full PHP binary path and the full script path. Relative paths often fail because cron does not run from your website directory.

/usr/local/bin/php /home/username/public_html/scripts/task.php

# WordPress example
/usr/local/bin/php /home/username/public_html/wp-cron.php

If your server exposes multiple PHP versions, use the PHP path shown by cPanel or ask support which binary matches the domain's selected PHP version.

Email and logging

Cron emails command output to the configured address. For routine jobs, redirect output to a log file so your mailbox is not flooded:

/usr/local/bin/php /home/username/public_html/task.php >> /home/username/cron-task.log 2>&1

Review and rotate log files periodically so they do not grow without limit.

Troubleshooting cron jobs

ProblemWhat to check
No outputTemporarily remove output redirection or send output to a log file.
Script not foundUse an absolute path such as /home/username/public_html/script.php.
Wrong PHP versionUse the PHP binary that matches the domain's configured version.
Permission deniedCheck file permissions and whether the script is readable by your account user.
Job causes high usageRun it less frequently, optimize the script, or move heavy tasks to VPS/dedicated hosting.

Related: How to set up cron jobs in cPanel | Error logs in cPanel: find PHP and website errors | Changing PHP version in cPanel (MultiPHP Manager) | cPanel File Manager: upload, edit, organize, and delete files

Was this article helpful?

Need cPanel hosting or licensing?

Use UnderHost cPanel hosting or add cPanel/WHM to a VPS or dedicated server for familiar website, email, DNS, and database management.

Related articles

Back to cPanel