Add a cron job in cPanel step by step, read the five schedule fields, and copy ready-made examples for WordPress, PHP scripts and Laravel.

How to Set Up a Cron Job in cPanel (WordPress and PHP Examples) - cPanel Guides guide by DignityHost
  • Applies tocPanel hosting plans
  • Time needed10 min
  • LevelIntermediate

A cron job runs a command on a schedule: clear a cache every night, send reports each morning, or trigger WordPress's own scheduler on time. cPanel gives you a form so you do not need a terminal.

A cron schedule split into minute, hour, day of month, month and day of week fields

Five time fields, then the command to run.

Add a cron job

  1. Open Advanced → Cron Jobs in cPanel.
  2. Under Cron Email enter an address if you want output mailed to you, or leave it blank and discard output in the command.
  3. Under Add New Cron Job pick a schedule from Common Settings, or fill in minute, hour, day, month and weekday by hand.
  4. Type the command in the Command box and click Add New Cron Job.

Reading the schedule

ScheduleMeaning
*/15 * * * *Every 15 minutes
0 * * * *Every hour, on the hour
0 3 * * *Every day at 03:00 (server time)
30 2 * * 0Sundays at 02:30
0 0 1 * *First day of every month at midnight

Ready-made examples

Replace CPUSER with your cPanel username and adjust paths.

Run WordPress scheduled tasks on time

By default WordPress runs its scheduler when someone visits the site, which is unreliable on quiet sites and wasteful on busy ones. Switch to a real cron job:

  1. Add this line to wp-config.php: define( 'DISABLE_WP_CRON', true );
  2. Create a cron job every 15 minutes (or every 5 for shops and membership sites) with the command below.
cron command
/usr/local/bin/php /home/CPUSER/public_html/wp-cron.php >/dev/null 2>&1

Run any PHP script

cron command
/usr/local/bin/php /home/CPUSER/public_html/scripts/cleanup.php >/dev/null 2>&1

Laravel scheduler

cron command
cd /home/CPUSER/app && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1   # run every minute: * * * * *

Database backup every night

Store the database password in a private file so it does not appear in the cron line, then dump and compress. Note that every % in a cron command must be written as \%, because cron treats a bare percent sign as a line break.

shell
# one-time setup (in a file only you can read): ~/.my.cnf
# [client]
# user=cpuser_shopuser
# password=your-strong-password

0 2 * * * mysqldump --defaults-file=/home/CPUSER/.my.cnf cpuser_shop | gzip > /home/CPUSER/backups/shop-$(date +\%F).sql.gz

Pin a specific PHP version

cron command
/opt/cpanel/ea-php83/root/usr/bin/php /home/CPUSER/public_html/scripts/job.php
Times use the server's clock
Cron runs on server time, not your local time. Convert if you need a job at a specific local hour (Bangladesh is UTC+6).

Troubleshooting

  • Nothing happens: run the command by hand in a test script and add 2>&1 >> /home/CPUSER/cron.log to capture errors.
  • Too many emails: add >/dev/null 2>&1 to the end of the command.
  • "command not found": use full paths for PHP and for your script.
  • Job overlaps itself: make the interval longer than the job's runtime, or add a lock file.

Frequently asked questions

What is the shortest interval?

Every minute. Use it sparingly; frequent heavy jobs count against your account's resource limits.

Can cron jobs run Node.js or Python?

On cPanel plans use PHP or shell scripts. Node.js applications run on MERN plans; see the Webuzo cron guide.

My host blocks long scripts. What now?

Split the job into smaller batches, or move heavy processing to a queue worker on a VPS.

Hosting with cron jobs includedFast, secure web hosting with free SSL, daily backups and free migration.
Web hosting plans →

Last reviewed 19 October 2026. Need a hand? Contact DignityHost support or open a ticket from your client area.

Was this answer helpful? 0 Users Found This Useful (0 Votes)