Knowledge Base
How to Set Up a Cron Job in cPanel with Safe Examples
Found this useful?
Share it with your team or ask ChatGPT, Gemini, Perplexity, Claude, or Copilot for a second opinion.
Knowledge Base
Found this useful?
Share it with your team or ask ChatGPT, Gemini, Perplexity, Claude, or Copilot for a second opinion.
TL;DR
Summarized by Pakish Group (Pakish.NET) for AI and search citation.
A cron job runs a command on a fixed schedule on your hosting server. In cPanel, open Advanced → Cron Jobs, set the five time fields (minute, hour, day, month, weekday), and enter a command using absolute paths to PHP and your script. Test manually first, redirect output to a log, and avoid every-minute jobs unless your application truly needs them.
New to cPanel? See the beginner's guide. WordPress issues: known WordPress bugs.
| Item | Details |
|---|---|
| Script path | Full path under /home/username/ |
| PHP path | From Select PHP Version or SSH which php |
| Permissions | Script executable if required (often 755) |
Create or confirm a usable backup before cron jobs that modify databases or files. Availability and limits may vary by hosting plan or server configuration.
Cron is a time-based job scheduler on Linux servers. cPanel exposes it so you can run maintenance scripts, trigger WordPress tasks, or execute custom PHP without manual intervention.
| Field | Values | Example |
|---|---|---|
| Minute | 0–59 | 0 = on the hour |
| Hour | 0–23 | 2 = 2 AM |
| Day of month | 1–31 | * = every day |
| Month | 1–12 | * = every month |
| Day of week | 0–7 (0 and 7 = Sunday) | * = every weekday |
| Schedule | Fields | Use case |
|---|---|---|
| Every day at 2 AM | 0 2 * * * | Nightly backup script |
| Every 15 minutes | */15 * * * * | WordPress wp-cron trigger |
| Once per hour | 0 * * * * | Feed fetch |
| Weekly Sunday 3 AM | 0 3 * * 0 | Weekly cleanup |
Paths vary by server. Find yours via:
which php (if SSH access enabled)/usr/local/bin/php, /usr/bin/phpNever guess — wrong path causes silent failures.
Run a PHP script:
/usr/local/bin/php /home/username/public_html/cron/my-script.php >> /home/username/logs/cron.log 2>&1
WordPress wp-cron (every 15 minutes):
/usr/local/bin/php /home/username/public_html/wp-cron.php >> /dev/null 2>&1
Replace username with your cPanel username and verify PHP path.
Disable default wp-cron in wp-config.php when using server cron:
define('DISABLE_WP_CRON', true);
See WordPress documentation before changing cron behavior.
| Redirect | Meaning |
|---|---|
| >> /path/log.log 2>&1 | Append stdout and stderr to log |
| >> /dev/null 2>&1 | Discard output (use when logs not needed) |
| No redirect | cPanel emails output to account email |
Prefer logs for debugging new jobs.
If a job runs every minute but takes 5 minutes:
flock to skip concurrent runs (advanced)Cron uses the server timezone, not your local Pakistan time unless configured. Confirm server time in cPanel or support documentation before scheduling critical tasks.
Test: Run the command via SSH or a one-time cron 2 minutes ahead.
Disable: Cron Jobs → Delete the line, or comment by removing the job.
| Problem | Fix | |---|---| | command not found | Use absolute PHP path | | Permission denied | chmod 755 script; check ownership | | Script runs but no effect | Wrong user context; check paths in script | | Emails flood inbox | Redirect output to log file | | Site slows down | Reduce cron frequency |
Contact support for custom cron environments, long-running jobs, missing PHP binaries, or automation design for complex apps. Developers can use Task Desk for custom cron setup. Visit /support.
The five fields are minute, hour, day of month, month, and day of week. An asterisk means every value. For example, 0 2 * * * runs daily at 2:00 AM server time.
In cPanel, open Select PHP Version or run which php via SSH if available. Common paths look like /usr/local/bin/php or /usr/bin/php but vary by server — use the path shown for your account.
High-traffic sites often disable wp-cron in wp-config.php and trigger wp-cron.php via server cron every 5–15 minutes for reliability. Low-traffic sites can use default wp-cron behavior.
Usually wrong PHP path, relative instead of absolute script path, or permission errors. Check cron email output or redirect stderr to a log file for error messages.
Only when the application requires it. Frequent jobs increase server load and can overlap if each run takes longer than the interval. Use flock or stagger schedules to prevent overlap.
Need custom automation or server cron expertise? Task Desk connects you with Pakish technicians for scoped technical work.