Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Set Up a Cron Job in cPanel

A cron job runs a task on its own at times you choose. This guide shows how to make one in cPanel.

Website Management2 min read8 steps3 screenshots

What is a cron job?

Imagine an alarm clock that, instead of ringing, runs a small program. That is a cron job. You can use it to run a PHP script every night, clear a folder each week, or send a daily report. Cron is the name of the time scheduler on Linux servers.

How the timing works

A cron time has five parts, in this order:

MinuteHourDayMonthWeekday
0 to 590 to 231 to 311 to 120 to 6 (Sunday is 0)

A star * means "every". So 30 2 * * * means 2:30 in the morning, every day.

Steps

  1. Log in to cPanel. The link is in your welcome email.
  2. In the Advanced section, click Cron Jobs.
  3. Under Cron Email, type an email address if you want reports. Click Update Email.
    cPanel Cron Emails
  4. Under Add New Cron Job, pick a time from Common Settings, such as Once Per Day. The boxes fill in for you.
  5. In the Command box, type what should run. Example for a PHP script:
    /usr/local/bin/php /home/username/public_html/script.php
    This command runs the file script.php with PHP. Replace username with your cPanel username. The PHP path may differ on your server, so check with Hostvento support if it fails.
  6. Click Add New Cron Job.
    cPanel Cron Jobs

Your new job now shows in the list under Current Cron Jobs.

Stop the email spam

By default, cron emails you the output every run. To stop this, add this to the end of the command:

 >/dev/null 2>&1

It throws the output away.

Edit or delete a job

  1. Go back to the Current Cron Jobs list.
  2. Click Edit to change a job, or Delete to remove it.
Tip: Do not run a job every minute unless you must. It can slow down your site. Also, a wrong command can change your files, so take a backup first.

Quick recap

  • A cron job runs a task on a schedule.
  • Times have five parts: minute, hour, day, month, weekday.
  • Open Cron Jobs in cPanel and pick a time.
    cPanel Add New Cron Jobs
  • Type the command and click Add New Cron Job.
  • Add >/dev/null 2>&1 to stop emails.