How to Use Cron Jobs Feature on cPanel

Introduction

In this guide, you will learn how to use Cron Jobs feature. Cron jobs allow you to automate certain commands or scripts on your site. You can set a command or script to run at a specific time every day, week, etc. For example, you could set a Cron job to delete temporary files every week to free up disk space.

What you’ll need

Before you begin this guide you’ll need the following:

  • Access to your cPanel account.
  • A PHP script or a Linux command that you want to automate.
  • Good knowledge of Linux commands before you can use Cron jobs effectively.


Step 1 — Accessing your cPanel and locating Cron Jobs feature

Access your cPanel using your login credentials. Afterwards, you will need to find the Cron Jobs feature, which is located under Advanced section.

Crons


Step 2 — Adding Cron Email

  • Cron Email feature sends an email with the output of your command, if any, every time the Cron job runs. You can have Cron send an email every time it runs a command which produces output. If you do not want an email to be sent for an individual cron job you can redirect the command’s output to /dev/null like this: mycommand >/dev/null 2>&1.
  • If You want to use this feature, simply input your email address in the Email field and click Update Email button below.

 

Cron email


Step 3 — Adding a new Cron job

To add a new Cron job, it is required to fill out the following fields:

  • Common Settings. This dropdown menu allows you to select a predefined setting for your command, you can either use this feature to setup the time for you or you can use custom time values in the fields below.
  • Minute. This field is used to specify the minute value when your command will run.
  • Hour. This field is used to specify the hour value when your command will run.
  • Day. This field is used to specify the day value when your command will run.
  • Month. This field is used to specify the month value when your command will run.
  • Weekday. This field is used to specify the weekday value when your command will run.
  • Command. In this field, you must enter the Linux command that will run at the times specified by the fields above. For example, you can use this command to run a PHP script located in your public_html directory at the specified times: php -f /home/YOUR_CPANEL_USERNAME/public_html/file.php
    IMPORTANT! You must insert your actual cPanel username instead of YOUR_CPANEL_USERNAME

 


Cron add

Click Add New Cron Job button. After clicking the button You will see cPanel successfully added the cron job. message, this means that the Cron job was added successfully.

Cron add confirm

Step 4 — Removing and editing existing Cron jobs

To remove Your current Cron job, perform the following steps:

Cron delete

  • Click the Delete icon next to the Cron job that you want to remove.

Cron delete conf

  • Click Delete button. 

To edit Your current Cron job, perform the following steps:

Cron edit

  • Click the Edit icon next to the Cron job that you want to edit.

Cron edit conf

  • Update Your settings with new settings and click the Edit Line button.


Conclusion

After following this guide you will be able to add, remove and edit Cron jobs to automate commands or scripts on your website.

  • 28 Users Found This Useful
Was this answer helpful?

Related Articles

How to add A Record in cPanel using DNS Zone Editor?

A Record is a DNS record and is used to point a domain or subdomain to an IP address. You can add...

How to edit or remove CNAME Record in cPanel using the DNS Zone Editor?

You can edit or remove CNAME Record from cPanel using the cPanel DNS Zone Editor which allows you...

How to Update a Cronjob E-mail Address?

If you want to receive a cronjob error or notification, you can update your e-mail address from...

How to Edit .htaccess File via the cPanel Filemanager?

1. Log into your cPanel account. 2. In the "Files" section, click on "File Manger" Icon. 3....

How to Keep Your cPanel Contact Information Up To Date

This tutorial will teach you how to keep your contact information up to date in cPanel. It is...