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 update your cPanel Contact Information or receive a notification on reaching quota limit?

If you want to receive notification on reaching your disk quota, bandwidth usage limit, reaching...

How to Change cPanel Style/Theme?

Switching over to another cPanel theme with a different style is easy and there are two ways to...

How to Edit file in the cPanel File Manager?

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

How to Change Language of your cPanel?

cPanel supports a lot of languages, and if you want to change your cPanel language to your native...

How to Reset my cPanel Account Password?

If you can access your cPanel account, follow these steps to reset your password:1. Log into your...