£ GBP

Setting Up a Cron Job in cPanel

Print
  • 0

What a cron job is

A cron job is a task your server runs automatically on a schedule, every hour, every night, once a week, whatever you set. Instead of you remembering to run something, the server does it for you, on time, every time. The name is old Unix tradition; the idea is just "a scheduled task."

Most website owners never need to touch cron, the software they run handles its own scheduling. You reach for it when something specifically tells you to set one up: a script that needs to run regularly, a backup routine, or the WordPress case covered below.

When you'd actually use one

  • A WordPress performance fix. The most common real use. WordPress has its own built-in scheduler, wp-cron, which runs on every page visit, and on a busy site that is wasteful. The standard fix is to switch it off and run it from a proper cron job on a fixed schedule instead, which is lighter and more reliable.
  • A script a developer gave you that needs to run on a schedule, a data sync, a cleanup routine, a report.
  • A custom backup or maintenance task you want to happen automatically at a quiet hour.

If nothing has told you to set up a cron job, you almost certainly do not need one, so this is a "follow the instructions you were given" article rather than something to set up speculatively.

Setting one up

  1. Log in to cPanel at yourdomain.tld/cpanel and open Cron Jobs, findable via the search box.
  2. Set the schedule, how often the job runs. cPanel offers common presets (once an hour, once a day, and so on), or you can set a specific time. Pick the preset that matches what you were told to use.
  3. Enter the command, the exact instruction to run. Whatever set you on this, your script's documentation, a plugin's guidance, a developer, will give you the precise command to paste here. Paste it exactly rather than retyping it, cron commands are unforgiving of typos.
  4. Add the cron job. It now runs on the schedule you set, with nothing further from you.

You can set an email address to be notified each time the job runs, useful while testing, though you will usually want to turn that off once you know it works, or your inbox fills with run notifications.

The one rule: don't schedule it too often

This is the part that matters, so take it seriously. A cron job set to run every minute, or every few minutes, when it does not need to, is one of the easiest ways to put needless load on your hosting, and on shared hosting that affects your site's own performance. Unless something specifically and genuinely requires it, do not schedule a job more often than every fifteen minutes, and for most tasks once an hour or once a day is plenty. If a plugin or script insists on running every minute, that is worth questioning rather than obeying automatically.

Setting a job to run far more often than its work actually requires gains you nothing and costs you performance, so err toward less frequent, not more.

Where the safe steps end

Entering a cron job from a command you were given is safely DIY. Working out what the command should be, writing the script it runs, or diagnosing why a cron job is not doing what it should, is developer territory. If you have a task you want automated but no command to paste, or a cron job that is not behaving, open a support ticket, tell us what you are trying to achieve and how often, and we will help you set it up correctly, including the WordPress wp-cron switch, which we are glad to configure for you.

Good to know

Cron jobs are quietly powerful, and quietly easy to misuse, which is why the frequency rule is the thing to remember above all. Set a job only when something genuinely needs scheduling, run it no more often than it truly requires, and paste the command exactly as given, and cron is a reliable workhorse. The WordPress wp-cron switch is the one case worth knowing about proactively: if your WordPress site feels sluggish under traffic, moving its scheduler to a real cron job is a recognised fix, and a quick ticket gets it done.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution