How to Create a Cron Job in cPanel

Scheduling Automated Tasks With Cron Jobs

 

A cron job is a scheduled task that runs automatically at times you specify. Common uses include running maintenance scripts, sending scheduled emails, generating reports, cleaning up temporary files, and triggering WordPress scheduled tasks.

 

Setting Up a Cron Job

  1. Log into cPanel
  2. In the Advanced section, click Cron Jobs
  3. Under "Add New Cron Job," select the schedule from the dropdowns (or enter custom values)
  4. Enter the command to run
  5. Click Add New Cron Job

 

Common Cron Job Examples

 

Run a PHP script every hour:

/usr/local/bin/php /home/username/public_html/myscript.php

 

WordPress WP-Cron (run every 15 minutes):

/usr/local/bin/php /home/username/public_html/wp-cron.php >/dev/null 2>&1

This is useful if you have disabled WordPress built-in cron (by adding define('DISABLE_WP_CRON', true); to wp-config.php) and want a real server cron to handle scheduled tasks like publishing scheduled posts and sending email digests.

 

Fetch a URL every day at midnight:

/usr/bin/curl -s https://yourdomain.com/daily-task.php >/dev/null 2>&1

 

Understanding the Schedule

Cron uses five time fields: minute, hour, day of month, month, and day of week. cPanel provides common presets (once per minute, twice per hour, once per day, etc.) but you can set custom schedules. For example:

  • 0 * * * * = every hour on the hour
  • */15 * * * * = every 15 minutes
  • 0 3 * * * = every day at 3:00 AM server time
  • 0 0 * * 0 = every Sunday at midnight

 

Cron Email Notifications

By default, cron sends you an email with the output of each job. If your job runs frequently, this can fill your inbox. To suppress the emails, add >/dev/null 2>&1 to the end of your command. You can also set a notification email address at the top of the Cron Jobs page.

 

Tips

  • Always use full paths to PHP and your script files
  • Your cPanel username appears in the path: /home/yourusername/
  • Test your command via SSH or Terminal in cPanel first to make sure it works before scheduling it
  • On shared hosting, avoid scheduling jobs more frequently than once per minute to stay within resource limits
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Back Up Your Website

Backing Up Your Website Files and Databases   Regular backups are one of the most important...

How do I interpret hosting control panel access logs?

When viewing an access log from the hosting control panel there are many different variables to...

When loading the control panel I get an Invalid Syntax Error

Invalid Syntax Error When Loading cPanel   If you receive an "Invalid Syntax...

How do I use the Control Panel?

Using Your cPanel Hosting Control Panel   Your hosting control panel (cPanel) is where you...

How do I access the Control Panel?

Accessing Your cPanel Hosting Control Panel   There are several ways to access your cPanel...



Save 30% on web hosting - Use coupon code Hosting30