Help

What is a cron job? How to set one up in cPanel

A cron job is a command your server runs on a schedule, such as every 15 minutes or at 2 am each day. Each job has five time fields: minute, hour, day of the month, month and day of the week. In cPanel, you add cron jobs under Advanced › Cron Jobs.

Updated · HostUpIndia team

How cron job timing works

A cron job is one line: five time fields, then the command. In order, the fields are the minute (0–59), the hour (0–23), the day of the month (1–31), the month (1–12) and the day of the week (0–6, where 0 is Sunday).

An asterisk, *, means every value. */15 means every 15th value, 1-5 a range and 0,30 a list.

Times follow the server’s clock, which may not be on IST. Run date in cPanel › Terminal to see it.

  • */15 * * * * runs every 15 minutes.
  • 0 2 * * * runs at 2:00 am every day.
  • 0 9 * * 1-5 runs at 9:00 am, Monday to Friday.
  • 0 0 1 * * runs at midnight on the first day of each month.

What cron jobs are used for

Use cron for any task that should run on its own, on time.

  • Run WordPress’s scheduled tasks, such as scheduled posts and update checks.
  • Back up files or a database each night.
  • Send daily or weekly reports by email.
  • Clear caches and delete old temporary files.
  • Import feeds or sync data with another service.

How to set up a cron job in cPanel

Pick a schedule that suits the task. Don’t run heavy jobs every minute: they keep the account busy all day and can lead to 508 Resource Limit Is Reached.

  • Sign in to cPanel and open Advanced › Cron Jobs.
  • Under Cron Email, enter the address that should receive the jobs’ output, and select Update Email.
  • Under Add New Cron Job, choose a schedule from Common Settings, or fill in the Minute, Hour, Day, Month and Weekday fields.
  • In Command, enter the command to run. See the next section.
  • Select Add New Cron Job. The job appears under Current Cron Jobs.

What to put in the cron command

Cron runs without your usual settings, so use full paths. Your home directory, such as /home/username, is shown in cPanel under General Information.

  • To run a PHP script, enter php /home/username/public_html/cron.php, with your own home directory and file.
  • If the job reports php: command not found, use the full path to PHP. cPanel › Terminal shows it when you run which php, and support can tell you too.
  • To load a URL, enter wget -q -O - https://example.com/cron.php >/dev/null 2>&1, or curl -s https://example.com/cron.php >/dev/null 2>&1.
  • End a command with >/dev/null 2>&1 to stop its emails. Leave it off until the job works, so you see any errors.
  • To keep the output in a log instead, end the command with >> /home/username/cron.log 2>&1.
  • Put a backslash before any %, as in date +\%F. Cron reads a bare % as a new line.

Test, edit or delete a cron job

Test a command by hand before you trust its schedule.

  • Run the command in cPanel › Terminal and check the result.
  • For the first run, set the job to */5 * * * * and wait for the output email.
  • Once it works, edit the job to its real schedule.
  • To change a job, select Edit next to it under Current Cron Jobs.
  • Change the time or the command, then select Edit Line.
  • To remove a job, first copy its schedule and command somewhere safe.
  • Select Delete next to it, then confirm.
  • If a job fails, read its email or log. The usual causes are a wrong path, a file the job cannot read, or a bare %.

Use a real cron job for WordPress

WordPress runs its scheduled tasks, WP-Cron, only when someone visits the site. On a quiet site they run late; on a busy one, the checks add load. A real cron job runs them on time.

  • In cPanel › Cron Jobs, set Minute to */15 and leave the other fields as *.
  • Enter this command, with your own domain in place of example.com: wget -q -O - https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
  • Select Add New Cron Job.
  • In cPanel › File Manager, download a copy of wp-config.php.
  • Add define( 'DISABLE_WP_CRON', true ); to wp-config.php, above the line that says “stop editing”. Full steps: how to edit wp-config.php.
  • A day later, open Tools › Site Health in WordPress and check that it reports no late scheduled events.

HostUpIndia Web & cPanel Hosting

HostUpIndia Web & cPanel Hosting includes cPanel for the steps above, and terminal (SSH) access to test a command before you schedule it. Every plan also has LiteSpeed, NVMe storage, free SSL, the AI Website Builder and daily backups kept 30 days.

  • From ₹49 a month on 3-year billing. Prices exclude 18% GST. See Web & cPanel plans.
  • Support tickets and email are received 24 hours a day, 7 days a week; WhatsApp is open for questions from 10 am to 7 pm IST, Monday to Saturday.
  • Free website migration by the HostUpIndia in-house team.
  • More help guides.