How to set up CRON tasks on cPanel
A cron job is a command or script that the server runs on a schedule, with no action on your part. The schedule is written as a cron expression, five time fields followed by the command. This guide shows how to set up cron tasks on cPanel, write a cron expression and pick the right command. It also covers WordPress, email notifications and common errors.
Understand cron syntax
A cron expression has five time fields, followed by the command to run.
* * * * * command to run
│ │ │ │ │
│ │ │ │ └─── day of the week (0-7, 0 and 7 = Sunday)
│ │ │ └──────── month (1-12)
│ │ └───────────── day of the month (1-31)
│ └────────────────── hour (0-23)
└─────────────────────── minute (0-59)
Each field takes a number, or one of these characters.
| Character | Meaning | Example |
|---|---|---|
* | every value | * * * * *, every minute |
, | a list of values | 1,15,30, at minutes 1, 15 and 30 |
- | a range of values | 1-5, from 1 to 5 |
/ | a step | */15, every 15 units |
Months can also be written jan to dec, and days sun to sat.
| Expression | Runs |
|---|---|
*/5 * * * * | every 5 minutes |
*/15 * * * * | every 15 minutes |
0 * * * * | every hour, at minute 0 |
0 */2 * * * | every 2 hours |
0 0 * * * | every day at midnight |
30 4 * * * | every day at 4:30 am |
0 0 * * 0 | every Sunday at midnight |
0 0 * * 1-5 | Monday to Friday at midnight |
0 0 1 * * | on the 1st of every month at midnight |
0 8,12,18 * * * | at 8 am, noon and 6 pm every day |
0 9-17 * * 1-5 | every hour from 9 am to 5 pm, Monday to Friday |
To check an expression, paste it into crontab.guru. The site explains it in plain words and lists its next runs.
Open Cron Jobs in cPanel
Cron jobs are not set in the client area. On your hosting page, click Advanced panel at the top right. cPanel opens straight away, with no login details to type. In the Advanced section, click Cron Jobs.
The page has three parts. Cron Email, Add New Cron Job and Current Cron Jobs.
Choose the notification address
When a job produces output or an error, cPanel sends it by email. Choose an address you read.
Under Cron Email, enter the address in the Email field, then click Update Email.

A job that runs often quickly fills the mailbox. Add
> /dev/null 2>&1at the end of its command to stop receiving its messages.
Add a cron job
Under Add New Cron Job, pick a frequency in Common Settings, or fill in the Minute, Hour, Day, Month and Weekday fields.
In Command, enter the full command, with absolute paths.
Click Add New Cron Job.
The job appears under Current Cron Jobs. It runs at the next time its expression matches.

The Common Settings list fills in the five fields for you.
| Choice | Expression |
|---|---|
| once per minute | * * * * * |
| once per five minutes | */5 * * * * |
| twice per hour | 0,30 * * * * |
| once per hour | 0 * * * * |
| twice per day | 0 0,12 * * * |
| once per day | 0 0 * * * |
| once per week | 0 0 * * 0 |
| once per month | 0 0 1 * * |
Find the path to PHP
cPanel itself shows two PHP command templates above the form.
/usr/local/bin/phpruns the server's default PHP version./usr/local/bin/ea-phpXXruns a specific version. ReplaceXXwith your domain's version, for exampleea-php83for PHP 8.3.
Each domain's version is shown in cPanel's MultiPHP Manager, or in the PHP version tab of the client area. The guide How to change the PHP version on cPanel explains it. Use the same version as the site, or the script may behave differently from the live site.
Command examples
In these examples, replace user with your cPanel username and mysite.com with your domain.
# Run a PHP script
/usr/local/bin/php /home/user/public_html/script.php
# Call a URL with wget
/usr/bin/wget -q -O /dev/null "https://mysite.com/cron.php"
# Call a URL with curl
/usr/bin/curl -s "https://mysite.com/cron.php" > /dev/null 2>&1
# Delete .tmp files older than one day in the cache
/usr/bin/find /home/user/public_html/cache -name "*.tmp" -mtime +1 -delete
# Delete files older than 7 days in a folder
/usr/bin/find /home/user/public_html/tmp -type f -mtime +7 -delete
| Option | Role |
|---|---|
-q (wget), -s (curl) | quiet mode |
-O /dev/null | does not keep the downloaded page |
> /dev/null 2>&1 | discards output and errors, so no email |
Always put a URL in quotes. Otherwise a ? or an & in the URL is interpreted by the system.
| Need | Expression | Command |
|---|---|---|
| backup script every night at 3 am | 0 3 * * * | /usr/local/bin/php /home/user/public_html/backup.php > /dev/null 2>&1 |
| clear a cache every 6 hours | 0 */6 * * * | /usr/local/bin/php /home/user/public_html/clear_cache.php |
| report every Monday at 9 am | 0 9 * * 1 | /usr/local/bin/php /home/user/public_html/weekly_report.php |
| expired sessions every night at 2:30 am | 30 2 * * * | /usr/bin/find /home/user/tmp/sessions -type f -mtime +1 -delete |
Archive files or a database
In a cron command, the % character has a special meaning. Write it as \%, as in the dates below.
# Archive the site into a dated archive
/usr/bin/tar -czf /home/user/backups/site_$(date +\%Y\%m\%d).tar.gz /home/user/public_html
# Export a database, with the credentials in a protected file
/usr/bin/mysqldump --defaults-extra-file=/home/user/.my.cnf user_database > /home/user/backups/database_$(date +\%Y\%m\%d).sql
The .my.cnf file, placed outside public_html with permission 600, holds the database credentials. The password therefore never appears in the command.
[client]
user=user_wpuser
password=your_password
OuiHeberg already backs up your files and databases. The Backups tab of the client area describes this backup. A cron archive comes on top of it, and uses disk space.
Replace WP-Cron with a real cron job
WordPress runs its scheduled tasks (WP-Cron) when someone visits the site. On a quiet site they run late. On a busy site they run too often. A cron job runs them at a steady interval.
In
wp-config.php, add this line before/* That's all, stop editing! */.
define('DISABLE_WP_CRON', true);
Create a cron job with one of these commands, for example every 15 minutes (
*/15 * * * *).
# With wget
/usr/bin/wget -q -O /dev/null "https://mysite.com/wp-cron.php?doing_wp_cron" > /dev/null 2>&1
# With curl
/usr/bin/curl -s "https://mysite.com/wp-cron.php?doing_wp_cron" > /dev/null 2>&1
# With PHP, without going through the web
cd /home/user/public_html && /usr/local/bin/php wp-cron.php > /dev/null 2>&1
| Type of site | Suggested frequency |
|---|---|
| personal blog | every hour (0 * * * *) |
| business site | every 30 minutes (*/30 * * * *) |
| WooCommerce shop | every 15 minutes (*/15 * * * *) |
| high-traffic site | every 5 minutes (*/5 * * * *) |
Edit or delete a job
The Current Cron Jobs list shows each job with its time fields and its command.
Edit opens the job. Change what you need, then save the line.
Delete removes the job, after confirmation.

Fix common problems
The job does not run
Check the expression on crontab.guru.
Use absolute paths, for PHP and for the script.
Run the script through PHP (
/usr/local/bin/php script.php) rather than directly.Open the script's URL in your browser, if it has one, to see whether it works.
See the errors
Remove > /dev/null 2>&1 from the command. The next run will send its output and errors to the notification address. You can also write to a log file, which you read with the File Manager.
/usr/local/bin/php /home/user/public_html/script.php >> /home/user/logs/cron.log 2>&1
For a first test, schedule the job a few minutes ahead, wait for it to run, then set the frequency you want.
Frequent error messages
/bin/sh: /home/user/public_html/script.php: No such file or directory
The path is wrong, or the file does not exist. Check it in the File Manager.
/bin/sh: /home/user/public_html/script.php: Permission denied
The script is not executable. Run it through the PHP interpreter, as in the examples. You can also give it permission 755 in the File Manager or with your FTP client.
/bin/sh: php: command not found
The command does not use a full path. Write /usr/local/bin/php instead of php.
To test your commands on the command line, SSH is available on request on every web hosting plan. Open a ticket to have it enabled.
Good practice
Do not run a job every minute without a reason. Choose the frequency the script really needs.
Spread heavy jobs over time rather than running them all at midnight.
Never put a password in plain text in a command.
Keep sensitive scripts outside
public_html, so nobody can call them from the web.Delete the jobs you no longer use.
# Lower the priority of a heavy script
nice -n 15 /usr/local/bin/php /home/user/public_html/script.php
# Receive no email
/usr/local/bin/php /home/user/script.php > /dev/null 2>&1
# Keep a trace in a log file
/usr/local/bin/php /home/user/script.php >> /home/user/logs/cron.log 2>&1
Need help?
Open a ticket from Tickets › Open a ticket (dash.ouiheberg.com/tickets/new), or click the Contact support tile at the bottom of your hosting page. You can also ask your question on our Discord.
cPanel hosting with email accounts and databases, managed from the OuiHeberg client area.
View plans →